mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-10-07 16:33:54 +00:00
Merge branch 'master' of gitee.com:openharmony/arkui_ace_engine into richtext
Signed-off-by: 李娟 <lijuan124@huawei.com>
This commit is contained in:
commit
737fb1cc89
@ -93,7 +93,7 @@ frameworks/core/components_ng/pattern/refresh/ @aryawang
|
||||
frameworks/core/components_ng/pattern/relative_container/ @nickyjd
|
||||
frameworks/core/components_ng/pattern/remote_window/ @liuchao92
|
||||
frameworks/core/components_ng/pattern/rendering_context/ @zhangbingce
|
||||
frameworks/core/components_ng/pattern/rich_editor/ @cc520bf
|
||||
frameworks/core/components_ng/pattern/rich_editor/ @jyj-0306
|
||||
frameworks/core/components_ng/pattern/root/ @zhoutianer
|
||||
frameworks/core/components_ng/pattern/scroll/ @rongShao-Z
|
||||
frameworks/core/components_ng/pattern/scroll_bar/ @rongShao-Z
|
||||
@ -159,7 +159,7 @@ frameworks/core/components/flex/ @yangfan229
|
||||
frameworks/core/components/focus_animation/ @catpoison
|
||||
frameworks/core/components/focus_collaboration/ @catpoison
|
||||
frameworks/core/components/focusable/ @catpoison
|
||||
frameworks/core/components/font/ @cc520bf
|
||||
frameworks/core/components/font/ @jyj-0306
|
||||
frameworks/core/components/foreach/ @yan-shuifeng
|
||||
frameworks/core/components/form/ @wangchensu1
|
||||
frameworks/core/components/gesture_listener/ @zheng-qiyi
|
||||
@ -367,7 +367,7 @@ frameworks/core/components_ng/test/pattern/refresh/ @suiwuyue
|
||||
frameworks/core/components_ng/test/pattern/relative_container/ @nickyjd
|
||||
frameworks/core/components_ng/test/pattern/remote_window/ @liuchao92
|
||||
frameworks/core/components_ng/test/pattern/rendering_context/ @zhangbingce
|
||||
frameworks/core/components_ng/test/pattern/rich_editor/ @cc520bf
|
||||
frameworks/core/components_ng/test/pattern/rich_editor/ @jyj-0306
|
||||
frameworks/core/components_ng/test/pattern/root/ @yan-shuifeng
|
||||
frameworks/core/components_ng/test/pattern/scroll/ @suiwuyue
|
||||
frameworks/core/components_ng/test/pattern/scroll_bar/ @suiwuyue
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "system_defined_form.h"
|
||||
#include "system_defined_pixelmap.h"
|
||||
#include "text.h"
|
||||
#include "plain_text.h"
|
||||
#include "udmf_client.h"
|
||||
#include "unified_data.h"
|
||||
#include "unified_data_napi.h"
|
||||
@ -240,30 +241,24 @@ void UdmfClientImpl::AddImageRecord(const RefPtr<UnifiedData>& unifiedData, cons
|
||||
udData->GetUnifiedData()->AddRecord(record);
|
||||
}
|
||||
|
||||
void UdmfClientImpl::AddTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr)
|
||||
void UdmfClientImpl::AddPlainTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr)
|
||||
{
|
||||
UDMF::UDVariant udmfValue(selectedStr);
|
||||
UDMF::UDDetails udmfDetails = { { "value", udmfValue } };
|
||||
auto record = std::make_shared<UDMF::Text>(udmfDetails);
|
||||
auto record = std::make_shared<UDMF::PlainText>(selectedStr, "");
|
||||
|
||||
auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData);
|
||||
CHECK_NULL_VOID(udData);
|
||||
udData->GetUnifiedData()->AddRecord(record);
|
||||
}
|
||||
|
||||
std::string UdmfClientImpl::GetSingleTextRecord(const RefPtr<UnifiedData>& unifiedData)
|
||||
std::string UdmfClientImpl::GetSinglePlainTextRecord(const RefPtr<UnifiedData>& unifiedData)
|
||||
{
|
||||
std::string str = "";
|
||||
auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData);
|
||||
CHECK_NULL_RETURN(udData, str);
|
||||
auto records = udData->GetUnifiedData()->GetRecords();
|
||||
if (records.size() >= 1 && records[0]->GetType() == UDMF::UDType::TEXT) {
|
||||
UDMF::Text* text = reinterpret_cast<UDMF::Text*>(records[0].get());
|
||||
UDMF::UDDetails udmfDetails = text->GetDetails();
|
||||
auto value = udmfDetails.find("value");
|
||||
if (value != udmfDetails.end()) {
|
||||
str = std::get<std::string>(value->second);
|
||||
}
|
||||
if (records.size() >= 1 && records[0]->GetType() == UDMF::UDType::PLAIN_TEXT) {
|
||||
UDMF::PlainText* plainText = reinterpret_cast<UDMF::PlainText*>(records[0].get());
|
||||
str = plainText->GetContent();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public:
|
||||
const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) override;
|
||||
void AddPixelMapRecord(const RefPtr<UnifiedData>& unifiedData, std::vector<uint8_t>& data) override;
|
||||
void AddImageRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& uri) override;
|
||||
void AddTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr) override;
|
||||
std::string GetSingleTextRecord(const RefPtr<UnifiedData>& unifiedData) override;
|
||||
void AddPlainTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr) override;
|
||||
std::string GetSinglePlainTextRecord(const RefPtr<UnifiedData>& unifiedData) override;
|
||||
int32_t GetVideoRecordUri(const RefPtr<UnifiedData>& unifiedData, std::string& uri) override;
|
||||
};
|
||||
|
||||
|
@ -28,41 +28,59 @@ namespace OHOS::Ace {
|
||||
namespace {
|
||||
const std::string MEDIA_PLUGIN = "multimedia/libmedialibrary.z.so";
|
||||
const std::string FILE_PLUGIN = "filemanagement/libuserfilemanager.z.so";
|
||||
const std::string PHOTO_HEAD = "file://media/Photo";
|
||||
const std::string AUDIO_HEAD = "file://media/Audio";
|
||||
const std::string PAH_PLUGIN = "file/libphotoaccesshelper.z.so";
|
||||
const std::string MEDIA_SERVER_HEAD = "datashare:///media";
|
||||
|
||||
#if !defined(PREVIEW)
|
||||
bool UseFilePlugin(const std::string& uri)
|
||||
{
|
||||
return StringUtils::StartWith(uri, PHOTO_HEAD) || StringUtils::StartWith(uri, AUDIO_HEAD);
|
||||
}
|
||||
|
||||
using ThumbnailNapiEntry = void* (*)(const char*, void*);
|
||||
ThumbnailNapiEntry GetThumbnailNapiEntry(const std::string& uri)
|
||||
static void* GetThumbnailFromNapi(const std::string& uri, const std::weak_ptr<OHOS::AbilityRuntime::Context> &context)
|
||||
{
|
||||
ACE_SCOPED_TRACE("GetThumbnailFromNapi");
|
||||
#if defined(_ARM64_) || defined(SIMULATOR_64)
|
||||
static const std::string PREFIX = "/system/lib64/module/";
|
||||
#else
|
||||
static const std::string PREFIX = "/system/lib/module/";
|
||||
#endif
|
||||
static const std::vector<std::string> THUMB_PLUGINS = {
|
||||
PAH_PLUGIN,
|
||||
FILE_PLUGIN,
|
||||
MEDIA_PLUGIN,
|
||||
};
|
||||
void* outThumbnail = nullptr;
|
||||
auto runtimeContext = context.lock();
|
||||
CHECK_NULL_RETURN(runtimeContext, nullptr);
|
||||
static ThumbnailNapiEntry thumbnailNapiEntry = nullptr;
|
||||
if (!thumbnailNapiEntry) {
|
||||
#if defined(_ARM64_) || defined(SIMULATOR_64)
|
||||
std::string prefix = "/system/lib64/module/";
|
||||
#else
|
||||
std::string prefix = "/system/lib/module/";
|
||||
#endif
|
||||
|
||||
auto napiPluginPath = prefix.append(UseFilePlugin(uri) ? FILE_PLUGIN : MEDIA_PLUGIN);
|
||||
void* handle = dlopen(napiPluginPath.c_str(), RTLD_LAZY);
|
||||
CHECK_NULL_RETURN(handle, nullptr);
|
||||
thumbnailNapiEntry = reinterpret_cast<ThumbnailNapiEntry>(dlsym(handle, "OHOS_MEDIA_NativeGetThumbnail"));
|
||||
if (thumbnailNapiEntry == nullptr) {
|
||||
dlclose(handle);
|
||||
LOGE("Failed to get symbol OHOS_MEDIA_NativeGetThumbnail in %{public}s", napiPluginPath.c_str());
|
||||
return nullptr;
|
||||
for (const auto& plug : THUMB_PLUGINS) {
|
||||
auto napiPlug = PREFIX + plug;
|
||||
void* handle = dlopen(napiPlug.c_str(), RTLD_LAZY);
|
||||
CHECK_NULL_RETURN(handle, nullptr);
|
||||
thumbnailNapiEntry = reinterpret_cast<ThumbnailNapiEntry>(dlsym(handle, "OHOS_MEDIA_NativeGetThumbnail"));
|
||||
if (thumbnailNapiEntry == nullptr) {
|
||||
dlclose(handle);
|
||||
LOGE("Failed to get symbol OHOS_MEDIA_NativeGetThumbnail in %{public}s, try next plugin",
|
||||
napiPlug.c_str());
|
||||
continue;
|
||||
}
|
||||
outThumbnail = thumbnailNapiEntry(uri.c_str(), &runtimeContext);
|
||||
if (outThumbnail == nullptr) {
|
||||
dlclose(handle);
|
||||
thumbnailNapiEntry = nullptr;
|
||||
LOGE("Failed to get thumbnail from %{private}s, try next plugin", napiPlug.c_str());
|
||||
continue;
|
||||
}
|
||||
return outThumbnail;
|
||||
}
|
||||
} else {
|
||||
outThumbnail = thumbnailNapiEntry(uri.c_str(), &runtimeContext);
|
||||
if (outThumbnail == nullptr) {
|
||||
thumbnailNapiEntry = nullptr;
|
||||
LOGE("Failed to get thumbnail!");
|
||||
}
|
||||
}
|
||||
return thumbnailNapiEntry;
|
||||
return outThumbnail;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
DataAbilityHelperStandard::DataAbilityHelperStandard(const std::shared_ptr<OHOS::AppExecFwk::Context>& context,
|
||||
@ -81,11 +99,7 @@ void* DataAbilityHelperStandard::QueryThumbnailResFromDataAbility(const std::str
|
||||
#ifdef PREVIEW
|
||||
return nullptr;
|
||||
#else
|
||||
ThumbnailNapiEntry thumbnailNapiEntry = GetThumbnailNapiEntry(uri);
|
||||
CHECK_NULL_RETURN(thumbnailNapiEntry, nullptr);
|
||||
auto runtimeContextSptr = runtimeContext_.lock();
|
||||
CHECK_NULL_RETURN(runtimeContextSptr, nullptr);
|
||||
return thumbnailNapiEntry(uri.c_str(), &runtimeContextSptr);
|
||||
return GetThumbnailFromNapi(uri, runtimeContext_);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "base/geometry/rect.h"
|
||||
#include "core/components/root/root_element.h"
|
||||
#include "core/components_ng/base/ui_node.h"
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
#if defined(ENABLE_ROSEN_BACKEND) and !defined(UPLOAD_GPU_DISABLED)
|
||||
#include "adapter/ohos/entrance/ace_rosen_sync_task.h"
|
||||
#endif
|
||||
@ -238,6 +239,7 @@ void SubwindowOhos::ShowPopupNG(int32_t targetId, const NG::PopupInfo& popupInfo
|
||||
CHECK_NULL_VOID(overlayManager);
|
||||
ShowWindow();
|
||||
ResizeWindow();
|
||||
ContainerScope scope(childContainerId_);
|
||||
overlayManager->UpdatePopupNode(targetId, popupInfo);
|
||||
}
|
||||
|
||||
@ -249,31 +251,11 @@ void SubwindowOhos::HidePopupNG(int32_t targetId)
|
||||
CHECK_NULL_VOID(context);
|
||||
auto overlayManager = context->GetOverlayManager();
|
||||
CHECK_NULL_VOID(overlayManager);
|
||||
auto popupInfo = overlayManager->GetPopupInfo(targetId);
|
||||
auto popupInfo = overlayManager->GetPopupInfo(targetId == -1 ? popupTargetId_ : targetId);
|
||||
popupInfo.popupId = -1;
|
||||
popupInfo.markNeedUpdate = true;
|
||||
overlayManager->HidePopup(targetId, popupInfo);
|
||||
context->FlushPipelineImmediately();
|
||||
HideWindow();
|
||||
#ifdef ENABLE_DRAG_FRAMEWORK
|
||||
HideEventColumn();
|
||||
HidePixelMap();
|
||||
HideFilter();
|
||||
#endif // ENABLE_DRAG_FRAMEWORK
|
||||
}
|
||||
|
||||
void SubwindowOhos::HidePopupNG()
|
||||
{
|
||||
auto aceContainer = Platform::AceContainer::GetContainer(childContainerId_);
|
||||
CHECK_NULL_VOID(aceContainer);
|
||||
auto context = DynamicCast<NG::PipelineContext>(aceContainer->GetPipelineContext());
|
||||
CHECK_NULL_VOID(context);
|
||||
auto overlayManager = context->GetOverlayManager();
|
||||
CHECK_NULL_VOID(overlayManager);
|
||||
auto popupInfo = overlayManager->GetPopupInfo(popupTargetId_);
|
||||
popupInfo.popupId = -1;
|
||||
popupInfo.markNeedUpdate = true;
|
||||
overlayManager->HidePopup(popupTargetId_, popupInfo);
|
||||
ContainerScope scope(childContainerId_);
|
||||
overlayManager->HidePopup(targetId == -1 ? popupTargetId_ : targetId, popupInfo);
|
||||
context->FlushPipelineImmediately();
|
||||
HideWindow();
|
||||
#ifdef ENABLE_DRAG_FRAMEWORK
|
||||
@ -383,6 +365,11 @@ void SubwindowOhos::HideWindow()
|
||||
}
|
||||
|
||||
OHOS::Rosen::WMError ret = window_->Hide();
|
||||
auto parentContainer = Platform::AceContainer::GetContainer(parentContainerId_);
|
||||
CHECK_NULL_VOID(parentContainer);
|
||||
if (parentContainer->IsScenceBoardWindow()) {
|
||||
window_->SetTouchable(true);
|
||||
}
|
||||
|
||||
if (ret != OHOS::Rosen::WMError::WM_OK) {
|
||||
LOGE("Hide window failed with errCode: %{public}d", static_cast<int32_t>(ret));
|
||||
@ -455,6 +442,7 @@ void SubwindowOhos::HideMenuNG()
|
||||
CHECK_NULL_VOID(context);
|
||||
auto overlay = context->GetOverlayManager();
|
||||
CHECK_NULL_VOID(overlay);
|
||||
ContainerScope scope(childContainerId_);
|
||||
overlay->HideMenuInSubWindow();
|
||||
}
|
||||
|
||||
@ -562,7 +550,7 @@ void SubwindowOhos::RectConverter(const Rect& rect, Rosen::Rect& rosenRect)
|
||||
}
|
||||
|
||||
RefPtr<NG::FrameNode> SubwindowOhos::ShowDialogNG(
|
||||
const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode)
|
||||
const DialogProperties& dialogProps, std::function<void()>&& buildFunc)
|
||||
{
|
||||
LOGI("SubwindowOhos::ShowDialogNG");
|
||||
auto aceContainer = Platform::AceContainer::GetContainer(childContainerId_);
|
||||
@ -572,9 +560,10 @@ RefPtr<NG::FrameNode> SubwindowOhos::ShowDialogNG(
|
||||
auto overlay = context->GetOverlayManager();
|
||||
CHECK_NULL_RETURN(overlay, nullptr);
|
||||
ShowWindow();
|
||||
window_->SetFullScreen(true);
|
||||
ResizeWindow();
|
||||
ContainerScope scope(childContainerId_);
|
||||
return overlay->ShowDialog(dialogProps, customNode);
|
||||
return overlay->ShowDialog(dialogProps, std::move(buildFunc));
|
||||
}
|
||||
|
||||
void SubwindowOhos::HideSubWindowNG()
|
||||
@ -700,7 +689,7 @@ void SubwindowOhos::ShowToastForAbility(const std::string& message, int32_t dura
|
||||
LOGE("can not get delegate.");
|
||||
return;
|
||||
}
|
||||
ContainerScope scope(aceContainer->GetInstanceId());
|
||||
ContainerScope scope(childContainerId_);
|
||||
auto parentContainer = Platform::AceContainer::GetContainer(parentContainerId_);
|
||||
CHECK_NULL_VOID(parentContainer);
|
||||
if (parentContainer->IsScenceBoardWindow()) {
|
||||
|
@ -64,14 +64,12 @@ public:
|
||||
void ShowPopup(const RefPtr<Component>& newComponent, bool disableTouchEvent = true) override;
|
||||
void ShowPopupNG(int32_t targetId, const NG::PopupInfo& popupInfo) override;
|
||||
void HidePopupNG(int32_t targetId) override;
|
||||
void HidePopupNG() override;
|
||||
void GetPopupInfoNG(int32_t targetId, NG::PopupInfo& popupInfo) override;
|
||||
bool CancelPopup(const std::string& id) override;
|
||||
void CloseMenu() override;
|
||||
void ClearMenu() override;
|
||||
void ClearMenuNG() override;
|
||||
RefPtr<NG::FrameNode> ShowDialogNG(
|
||||
const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode) override;
|
||||
RefPtr<NG::FrameNode> ShowDialogNG(const DialogProperties& dialogProps, std::function<void()>&& buildFunc) override;
|
||||
void HideSubWindowNG() override;
|
||||
bool GetShown() override
|
||||
{
|
||||
|
@ -255,10 +255,10 @@ public:
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
ContainerScope scope(instanceId_);
|
||||
taskExecutor->PostTask(
|
||||
[] {
|
||||
[instanceId = instanceId_] {
|
||||
SubwindowManager::GetInstance()->ClearMenu();
|
||||
SubwindowManager::GetInstance()->ClearMenuNG();
|
||||
SubwindowManager::GetInstance()->HidePopupNG();
|
||||
SubwindowManager::GetInstance()->ClearMenuNG(instanceId);
|
||||
SubwindowManager::GetInstance()->HidePopupNG(-1, instanceId);
|
||||
},
|
||||
TaskExecutor::TaskType::UI);
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ template("ace_osal_ohos_source_set") {
|
||||
"ace_engine_ext.cpp",
|
||||
"ace_trace.cpp",
|
||||
"anr_thread.cpp",
|
||||
"app_bar_helper_impl.cpp",
|
||||
"event_report.cpp",
|
||||
"exception_handler.cpp",
|
||||
"frame_report.cpp",
|
||||
@ -65,14 +66,10 @@ template("ace_osal_ohos_source_set") {
|
||||
"socperf_client_impl.cpp",
|
||||
"system_properties.cpp",
|
||||
"trace_id_impl.cpp",
|
||||
"ui_extension_helper_impl.cpp",
|
||||
"want_wrap_ohos.cpp",
|
||||
]
|
||||
|
||||
external_deps += [
|
||||
"init:libbegetutil",
|
||||
"window_manager:libwsutils",
|
||||
]
|
||||
external_deps += [ "init:libbegetutil" ]
|
||||
|
||||
if (is_ohos_standard_system) {
|
||||
sources += [
|
||||
@ -133,12 +130,15 @@ template("ace_osal_ohos_source_set") {
|
||||
external_deps += [
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hichecker:libhichecker",
|
||||
"hicollie:libhicollie",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:libhitracechain",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
deps += [
|
||||
"$ace_root/interfaces/inner_api/drawable_descriptor:drawable_descriptor",
|
||||
|
@ -13,13 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "core/common/ui_extension_helper.h"
|
||||
#include "core/common/app_bar_helper.h"
|
||||
|
||||
#include "bundlemgr/bundle_mgr_interface.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
#include "core/components_ng/pattern/ui_extension/ui_extension_model_ng.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string& bundleName,
|
||||
RefPtr<NG::FrameNode> AppBarHelper::CreateUIExtensionNode(const std::string& bundleName,
|
||||
const std::string& abilityName, const std::map<std::string, std::string>& params,
|
||||
std::function<void(int32_t)>&& onRelease,
|
||||
std::function<void(int32_t, const std::string&, const std::string&)>&& onError)
|
||||
@ -27,4 +31,25 @@ RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string
|
||||
return NG::UIExtensionModelNG::Create(bundleName, abilityName, params, std::move(onRelease), std::move(onError));
|
||||
}
|
||||
|
||||
std::string AppBarHelper::QueryAppGalleryBundleName()
|
||||
{
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
CHECK_NULL_RETURN(systemAbilityMgr, "");
|
||||
|
||||
auto bundleObj = systemAbilityMgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
CHECK_NULL_RETURN(bundleObj, "");
|
||||
|
||||
auto bundleMgr = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
CHECK_NULL_RETURN(bundleMgr, "");
|
||||
|
||||
std::string bundleName = "";
|
||||
auto result = bundleMgr->QueryAppGalleryBundleName(bundleName);
|
||||
if (!result) {
|
||||
LOGE("Query BundleName fail!");
|
||||
} else {
|
||||
LOGI("BundleName: %{public}s", bundleName.c_str());
|
||||
}
|
||||
return bundleName;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
@ -647,6 +647,7 @@ void GetFrameNodeChildren(const RefPtr<NG::UINode>& uiNode, std::vector<int32_t>
|
||||
{
|
||||
auto frameNode = AceType::DynamicCast<NG::FrameNode>(uiNode);
|
||||
if (AceType::InstanceOf<NG::FrameNode>(uiNode)) {
|
||||
CHECK_NULL_VOID_NOLOG(frameNode->IsActive());
|
||||
if (uiNode->GetTag() == "stage") {
|
||||
} else if (uiNode->GetTag() == "page") {
|
||||
if (uiNode->GetPageId() != pageId) {
|
||||
@ -830,10 +831,6 @@ void UpdateAccessibilityElementInfo(const RefPtr<NG::FrameNode>& node, const Com
|
||||
AccessibilityElementInfo& nodeInfo, const RefPtr<NG::PipelineContext>& ngPipeline)
|
||||
{
|
||||
CHECK_NULL_VOID_NOLOG(node);
|
||||
NG::RectF rect;
|
||||
if (node->IsActive()) {
|
||||
rect = node->GetTransformRectRelativeToWindow();
|
||||
}
|
||||
nodeInfo.SetParent(GetParentId(node));
|
||||
std::vector<int32_t> children;
|
||||
for (const auto& item : node->GetChildren()) {
|
||||
@ -852,6 +849,7 @@ void UpdateAccessibilityElementInfo(const RefPtr<NG::FrameNode>& node, const Com
|
||||
nodeInfo.SetInspectorKey(node->GetInspectorId().value_or(""));
|
||||
nodeInfo.SetVisible(node->IsVisible());
|
||||
if (node->IsVisible()) {
|
||||
auto rect = node->GetTransformRectRelativeToWindow();
|
||||
auto left = rect.Left() + commonProperty.windowLeft;
|
||||
auto top = rect.Top() + commonProperty.windowTop;
|
||||
auto right = rect.Right() + commonProperty.windowLeft;
|
||||
|
@ -52,13 +52,14 @@ static const std::set<std::string> stringAttrs = {
|
||||
"description_current_position",
|
||||
"description_paste",
|
||||
"description_download",
|
||||
"description_download_files",
|
||||
"description_download_file",
|
||||
"description_save",
|
||||
"description_save_images",
|
||||
"description_save_files",
|
||||
"description_save_image",
|
||||
"description_save_file",
|
||||
"description_download_and_share",
|
||||
"description_receive",
|
||||
"description_continue_to_receive",
|
||||
"draggable",
|
||||
};
|
||||
|
||||
double ParseDoubleUnit(const std::string& value, std::string& unit)
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include "parameter.h"
|
||||
#include "parameters.h"
|
||||
#include "scene_board_judgement.h"
|
||||
|
||||
#include "base/log/log.h"
|
||||
#include "base/utils/utils.h"
|
||||
@ -441,15 +440,4 @@ bool SystemProperties::IsFormAnimationLimited()
|
||||
return system::GetBoolParameter("persist.sys.arkui.formAnimationLimit", true);
|
||||
}
|
||||
|
||||
bool SystemProperties::IsSceneBoardEnabled()
|
||||
{
|
||||
return Rosen::SceneBoardJudgement::IsSceneBoardEnabled();
|
||||
}
|
||||
|
||||
void SystemProperties::GetAppBarInfo(std::string& bundleName, std::string& abilityName)
|
||||
{
|
||||
bundleName = system::GetParameter("persist.ace.appbar.bundlename", "");
|
||||
abilityName = system::GetParameter("persist.ace.appbar.abilityname", "");
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -62,6 +62,7 @@ ohos_source_set("preview_osal_source") {
|
||||
"ace_checker.cpp",
|
||||
"ace_engine_ext.cpp",
|
||||
"ace_trace.cpp",
|
||||
"app_bar_helper_impl.cpp",
|
||||
"event_report.cpp",
|
||||
"exception_handler.cpp",
|
||||
"fetch_manager.cpp",
|
||||
@ -75,7 +76,6 @@ ohos_source_set("preview_osal_source") {
|
||||
"stage_card_parser.cpp",
|
||||
"system_properties.cpp",
|
||||
"trace_id_impl.cpp",
|
||||
"ui_extension_helper_impl.cpp",
|
||||
]
|
||||
|
||||
cflags_cc = [
|
||||
|
@ -13,13 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "core/common/ui_extension_helper.h"
|
||||
#include "core/common/app_bar_helper.h"
|
||||
|
||||
#include "core/components_ng/pattern/ui_extension/ui_extension_model_ng.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string& bundleName,
|
||||
RefPtr<NG::FrameNode> AppBarHelper::CreateUIExtensionNode(const std::string& bundleName,
|
||||
const std::string& abilityName, const std::map<std::string, std::string>& params,
|
||||
std::function<void(int32_t)>&& onRelease,
|
||||
std::function<void(int32_t, const std::string&, const std::string&)>&& onError)
|
||||
@ -27,4 +27,9 @@ RefPtr<NG::FrameNode> UIExtensionHelper::CreateUIExtensionNode(const std::string
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string AppBarHelper::QueryAppGalleryBundleName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
@ -213,12 +213,4 @@ bool SystemProperties::GetImageFrameworkEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SystemProperties::IsSceneBoardEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SystemProperties::GetAppBarInfo(std::string& bundleName, std::string& abilityName) {}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -173,7 +173,6 @@ foreach(item, ace_platforms) {
|
||||
"hichecker:libhichecker",
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
"window_manager:libwsutils",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -44,14 +44,13 @@ public:
|
||||
virtual void ShowPopup(const RefPtr<Component>& newComponent, bool disableTouchEvent = true) = 0;
|
||||
virtual void ShowPopupNG(int32_t targetId, const NG::PopupInfo& popupInfo) = 0;
|
||||
virtual void HidePopupNG(int32_t targetId) = 0;
|
||||
virtual void HidePopupNG() = 0;
|
||||
virtual void GetPopupInfoNG(int32_t targetId, NG::PopupInfo& popupInfo) = 0;
|
||||
virtual bool CancelPopup(const std::string& id) = 0;
|
||||
virtual void CloseMenu() = 0;
|
||||
virtual void ClearMenu() {};
|
||||
virtual void ClearMenuNG() = 0;
|
||||
virtual RefPtr<NG::FrameNode> ShowDialogNG(
|
||||
const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode) = 0;
|
||||
const DialogProperties& dialogProps, std::function<void()>&& buildFunc) = 0;
|
||||
virtual void HideSubWindowNG() = 0;
|
||||
virtual int32_t GetChildContainerId() const = 0;
|
||||
virtual bool GetShown() = 0;
|
||||
|
@ -243,22 +243,21 @@ void SubwindowManager::ShowPopupNG(int32_t targetId, const NG::PopupInfo& popupI
|
||||
TaskExecutor::TaskType::PLATFORM);
|
||||
}
|
||||
|
||||
void SubwindowManager::HidePopupNG(int32_t targetId)
|
||||
void SubwindowManager::HidePopupNG(int32_t targetId, int32_t instanceId)
|
||||
{
|
||||
auto subwindow = GetCurrentWindow();
|
||||
RefPtr<Subwindow> subwindow;
|
||||
if (instanceId != -1) {
|
||||
// get the subwindow which overlay node in, not current
|
||||
subwindow = GetSubwindow(instanceId >= MIN_SUBCONTAINER_ID ? GetParentContainerId(instanceId) : instanceId);
|
||||
} else {
|
||||
subwindow = GetCurrentWindow();
|
||||
}
|
||||
|
||||
if (subwindow) {
|
||||
subwindow->HidePopupNG(targetId);
|
||||
}
|
||||
}
|
||||
|
||||
void SubwindowManager::HidePopupNG()
|
||||
{
|
||||
auto subwindow = GetCurrentWindow();
|
||||
if (subwindow) {
|
||||
subwindow->HidePopupNG();
|
||||
}
|
||||
}
|
||||
|
||||
void SubwindowManager::ShowPopup(const RefPtr<Component>& newComponent, bool disableTouchEvent)
|
||||
{
|
||||
auto containerId = Container::CurrentId();
|
||||
@ -326,16 +325,23 @@ void SubwindowManager::ClearMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void SubwindowManager::SetHotAreas(const std::vector<Rect>& rects, int32_t overlayId)
|
||||
void SubwindowManager::SetHotAreas(const std::vector<Rect>& rects, int32_t overlayId, int32_t instanceId)
|
||||
{
|
||||
auto subwindow = GetCurrentWindow();
|
||||
RefPtr<Subwindow> subwindow;
|
||||
if (instanceId != -1) {
|
||||
// get the subwindow which overlay node in, not current
|
||||
subwindow = GetSubwindow(instanceId >= MIN_SUBCONTAINER_ID ? GetParentContainerId(instanceId) : instanceId);
|
||||
} else {
|
||||
subwindow = GetCurrentWindow();
|
||||
}
|
||||
|
||||
if (subwindow) {
|
||||
subwindow->SetHotAreas(rects, overlayId);
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<NG::FrameNode> SubwindowManager::ShowDialogNG(
|
||||
const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode)
|
||||
const DialogProperties& dialogProps, std::function<void()>&& buildFunc)
|
||||
{
|
||||
auto containerId = Container::CurrentId();
|
||||
auto subwindow = GetSubwindow(containerId);
|
||||
@ -345,7 +351,7 @@ RefPtr<NG::FrameNode> SubwindowManager::ShowDialogNG(
|
||||
subwindow->InitContainer();
|
||||
AddSubwindow(containerId, subwindow);
|
||||
}
|
||||
return subwindow->ShowDialogNG(dialogProps, customNode);
|
||||
return subwindow->ShowDialogNG(dialogProps, std::move(buildFunc));
|
||||
}
|
||||
|
||||
void SubwindowManager::AddDialogSubwindow(int32_t instanceId, const RefPtr<Subwindow>& subwindow)
|
||||
|
@ -70,16 +70,15 @@ public:
|
||||
void HideMenuNG();
|
||||
void ShowPopup(const RefPtr<Component>& newComponent, bool disableTouchEvent = true);
|
||||
void ShowPopupNG(int32_t targetId, const NG::PopupInfo& popupInfo);
|
||||
void HidePopupNG(int32_t targetId);
|
||||
void HidePopupNG();
|
||||
void HidePopupNG(int32_t targetId, int32_t instanceId = -1);
|
||||
bool CancelPopup(const std::string& id);
|
||||
void CloseMenu();
|
||||
void ClearMenu();
|
||||
void ClearMenuNG(int32_t instanceId = -1);
|
||||
RefPtr<NG::FrameNode> ShowDialogNG(const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode);
|
||||
RefPtr<NG::FrameNode> ShowDialogNG(const DialogProperties& dialogProps, std::function<void()>&& buildFunc);
|
||||
void HideSubWindowNG();
|
||||
|
||||
void SetHotAreas(const std::vector<Rect>& rects, int32_t overlayId = -1);
|
||||
void SetHotAreas(const std::vector<Rect>& rects, int32_t overlayId = -1, int32_t instanceId = -1);
|
||||
|
||||
void AddDialogSubwindow(int32_t instanceId, const RefPtr<Subwindow>& subwindow);
|
||||
// Get the dialog subwindow of instance, return the window or nullptr.
|
||||
|
@ -30,7 +30,7 @@ std::shared_ptr<SubwindowManager> SubwindowManager::GetInstance()
|
||||
return instance_;
|
||||
}
|
||||
|
||||
void SubwindowManager::HidePopupNG(int32_t targetId)
|
||||
void SubwindowManager::HidePopupNG(int32_t targetId, int32_t instanceId)
|
||||
{
|
||||
LOGI("SubwindowManager::HidePopupNG MOCK");
|
||||
}
|
||||
@ -41,7 +41,7 @@ void SubwindowManager::HideMenuNG(int32_t targetId) {}
|
||||
|
||||
void SubwindowManager::HideMenuNG() {}
|
||||
|
||||
void SubwindowManager::SetHotAreas(const std::vector<Rect>& rects, int32_t overlayId) {}
|
||||
void SubwindowManager::SetHotAreas(const std::vector<Rect>& rects, int32_t overlayId, int32_t instanceId) {}
|
||||
|
||||
const RefPtr<Subwindow>& SubwindowManager::GetCurrentWindow()
|
||||
{
|
||||
|
@ -348,10 +348,6 @@ public:
|
||||
|
||||
static bool IsFormAnimationLimited();
|
||||
|
||||
static bool IsSceneBoardEnabled();
|
||||
|
||||
static void GetAppBarInfo(std::string& bundleName, std::string& abilityName);
|
||||
|
||||
private:
|
||||
static bool traceEnabled_;
|
||||
static bool svgTraceEnable_;
|
||||
|
@ -127,11 +127,6 @@ public:
|
||||
return eventHandler_;
|
||||
}
|
||||
|
||||
FrontendType GetType() override
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
// judge frontend is foreground frontend.
|
||||
bool IsForeground() override
|
||||
{
|
||||
@ -205,7 +200,6 @@ protected:
|
||||
void ParseManifest() const;
|
||||
|
||||
ColorMode colorMode_ = ColorMode::LIGHT;
|
||||
FrontendType type_ = FrontendType::JS_CARD;
|
||||
bool foregroundFrontend_ = false;
|
||||
bool pageLoaded_ = false;
|
||||
double density_ = 1.0;
|
||||
@ -217,7 +211,6 @@ protected:
|
||||
OnFormVisibleCallback onFormVisibleCallback_;
|
||||
|
||||
mutable std::once_flag onceFlag_;
|
||||
RefPtr<TaskExecutor> taskExecutor_;
|
||||
RefPtr<AceEventHandler> eventHandler_;
|
||||
Framework::PageIdPool pageIdPool_;
|
||||
std::string formSrc_;
|
||||
|
@ -210,6 +210,7 @@ template("declarative_js_engine") {
|
||||
"jsview/js_list_item_group.cpp",
|
||||
"jsview/js_loading_progress.cpp",
|
||||
"jsview/js_local_storage.cpp",
|
||||
"jsview/js_location_button.cpp",
|
||||
"jsview/js_marquee.cpp",
|
||||
"jsview/js_matrix2d.cpp",
|
||||
"jsview/js_menu.cpp",
|
||||
@ -224,6 +225,7 @@ template("declarative_js_engine") {
|
||||
"jsview/js_offscreen_rendering_context.cpp",
|
||||
"jsview/js_page_transition.cpp",
|
||||
"jsview/js_pan_handler.cpp",
|
||||
"jsview/js_paste_button.cpp",
|
||||
"jsview/js_path.cpp",
|
||||
"jsview/js_path2d.cpp",
|
||||
"jsview/js_pattern_lock.cpp",
|
||||
@ -243,14 +245,12 @@ template("declarative_js_engine") {
|
||||
"jsview/js_richeditor.cpp",
|
||||
"jsview/js_row.cpp",
|
||||
"jsview/js_row_split.cpp",
|
||||
"jsview/js_save_button.cpp",
|
||||
"jsview/js_scope_util.cpp",
|
||||
"jsview/js_scroll.cpp",
|
||||
"jsview/js_scroller.cpp",
|
||||
"jsview/js_search.cpp",
|
||||
"jsview/js_sec_button_base.cpp",
|
||||
"jsview/js_sec_location_button.cpp",
|
||||
"jsview/js_sec_paste_button.cpp",
|
||||
"jsview/js_sec_save_button.cpp",
|
||||
"jsview/js_select.cpp",
|
||||
"jsview/js_shape.cpp",
|
||||
"jsview/js_shape_abstract.cpp",
|
||||
|
@ -182,6 +182,7 @@ bool DeclarativeFrontend::Initialize(FrontendType type, const RefPtr<TaskExecuto
|
||||
{
|
||||
LOGD("DeclarativeFrontend initialize begin.");
|
||||
type_ = type;
|
||||
taskExecutor_ = taskExecutor;
|
||||
ACE_DCHECK(type_ == FrontendType::DECLARATIVE_JS);
|
||||
InitializeFrontendDelegate(taskExecutor);
|
||||
|
||||
|
@ -62,12 +62,12 @@ public:
|
||||
void PushPage(const std::string& url, const std::string& params) override;
|
||||
|
||||
// Js frontend manages all pages self.
|
||||
void AddPage(const RefPtr<AcePage>& page) override {};
|
||||
void AddPage(const RefPtr<AcePage>& page) override {}
|
||||
|
||||
RefPtr<AcePage> GetPage(int32_t /*pageId*/) const override
|
||||
{
|
||||
return nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
std::string GetCurrentPageUrl() const override;
|
||||
|
||||
@ -153,11 +153,6 @@ public:
|
||||
RefPtr<AceEventHandler> GetEventHandler() override
|
||||
{
|
||||
return handler_;
|
||||
};
|
||||
|
||||
FrontendType GetType() override
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
// judge frontend is foreground frontend.
|
||||
@ -237,7 +232,6 @@ protected:
|
||||
private:
|
||||
void InitializeFrontendDelegate(const RefPtr<TaskExecutor>& taskExecutor);
|
||||
|
||||
FrontendType type_ = FrontendType::DECLARATIVE_JS;
|
||||
RefPtr<AceEventHandler> handler_;
|
||||
RefPtr<Framework::JsEngine> jsEngine_;
|
||||
RefPtr<AccessibilityManager> accessibilityManager_;
|
||||
|
@ -1569,31 +1569,6 @@ var SecurityComponentLayoutDirection;
|
||||
SecurityComponentLayoutDirection[SecurityComponentLayoutDirection["VERTICAL"] = 1] = "VERTICAL";
|
||||
})(SecurityComponentLayoutDirection || (SecurityComponentLayoutDirection = {}));
|
||||
|
||||
var SecurityComponentLayoutOrder;
|
||||
(function (SecurityComponentLayoutOrder) {
|
||||
SecurityComponentLayoutOrder[SecurityComponentLayoutOrder["ICON_FIRST"] = 0] = "ICON_FIRST";
|
||||
SecurityComponentLayoutOrder[SecurityComponentLayoutOrder["TEXT_FIRST"] = 1] = "TEXT_FIRST ";
|
||||
})(SecurityComponentLayoutOrder || (SecurityComponentLayoutOrder = {}));
|
||||
|
||||
var SecLocationButtonLayoutDirection;
|
||||
(function (SecLocationButtonLayoutDirection) {
|
||||
SecLocationButtonLayoutDirection[SecLocationButtonLayoutDirection["HORIZONTAL"] = 0] = "HORIZONTAL";
|
||||
SecLocationButtonLayoutDirection[SecLocationButtonLayoutDirection["VERTICAL"] = 1] = "VERTICAL";
|
||||
})(SecLocationButtonLayoutDirection || (SecLocationButtonLayoutDirection = {}));
|
||||
|
||||
var SecLocationButtonLayoutOrder;
|
||||
(function (SecLocationButtonLayoutOrder) {
|
||||
SecLocationButtonLayoutOrder[SecLocationButtonLayoutOrder["ICON_FIRST"] = 0] = "ICON_FIRST";
|
||||
SecLocationButtonLayoutOrder[SecLocationButtonLayoutOrder["TEXT_FIRST"] = 1] = "TEXT_FIRST ";
|
||||
})(SecLocationButtonLayoutOrder || (SecLocationButtonLayoutOrder = {}));
|
||||
|
||||
var BackgroundButtonType;
|
||||
(function (BackgroundButtonType) {
|
||||
BackgroundButtonType[BackgroundButtonType["CAPSULE_BACKGROUND"] = 0] = "CAPSULE_BACKGROUND";
|
||||
BackgroundButtonType[BackgroundButtonType["CIRCLE_BACKGROUND"] = 1] = "CIRCLE_BACKGROUND";
|
||||
BackgroundButtonType[BackgroundButtonType["NORMAL_BACKGROUND"] = 2] = "NORMAL_BACKGROUND";
|
||||
})(BackgroundButtonType || (BackgroundButtonType = {}));
|
||||
|
||||
var LocationIconStyle;
|
||||
(function (LocationIconStyle) {
|
||||
LocationIconStyle[LocationIconStyle["FULL_FILLED"] = 0] = "FULL_FILLED";
|
||||
@ -1615,13 +1590,13 @@ var LocationDescription;
|
||||
LocationDescription[LocationDescription["CURRENT_POSITION"] = 10] = "CURRENT_POSITION";
|
||||
})(LocationDescription || (LocationDescription = {}));
|
||||
|
||||
var SecLocationButtonOnClickResult;
|
||||
(function (SecLocationButtonOnClickResult) {
|
||||
SecLocationButtonOnClickResult[SecLocationButtonOnClickResult["LOCATION_BUTTON_CLICK_SUCCESS"] = 0] =
|
||||
"LOCATION_BUTTON_CLICK_SUCCESS";
|
||||
SecLocationButtonOnClickResult[SecLocationButtonOnClickResult["LOCATION_BUTTON_CLICK_GRANT_FAILED"] = 1] =
|
||||
"LOCATION_BUTTON_CLICK_GRANT_FAILED ";
|
||||
})(SecLocationButtonOnClickResult || (SecLocationButtonOnClickResult = {}));
|
||||
var LocationButtonOnClickResult;
|
||||
(function (LocationButtonOnClickResult) {
|
||||
LocationButtonOnClickResult[LocationButtonOnClickResult["SUCCESS"] = 0] =
|
||||
"SUCCESS";
|
||||
LocationButtonOnClickResult[LocationButtonOnClickResult["TEMPORARY_AUTHORIZATION_FAILED"] = 1] =
|
||||
"TEMPORARY_AUTHORIZATION_FAILED ";
|
||||
})(LocationButtonOnClickResult || (LocationButtonOnClickResult = {}));
|
||||
|
||||
var PasteIconStyle;
|
||||
(function (PasteIconStyle) {
|
||||
@ -1633,13 +1608,13 @@ var PasteDescription;
|
||||
PasteDescription[PasteDescription["PASTE"] = 0] = "PASTE";
|
||||
})(PasteDescription || (PasteDescription = {}));
|
||||
|
||||
var SecPasteButtonOnClickResult;
|
||||
(function (SecPasteButtonOnClickResult) {
|
||||
SecPasteButtonOnClickResult[SecPasteButtonOnClickResult["SUCCESS"] = 0] =
|
||||
var PasteButtonOnClickResult;
|
||||
(function (PasteButtonOnClickResult) {
|
||||
PasteButtonOnClickResult[PasteButtonOnClickResult["SUCCESS"] = 0] =
|
||||
"SUCCESS";
|
||||
SecPasteButtonOnClickResult[SecPasteButtonOnClickResult["TEMPORARY_AUTHORIZATION_FAILED"] = 1] =
|
||||
PasteButtonOnClickResult[PasteButtonOnClickResult["TEMPORARY_AUTHORIZATION_FAILED"] = 1] =
|
||||
"TEMPORARY_AUTHORIZATION_FAILED ";
|
||||
})(SecPasteButtonOnClickResult || (SecPasteButtonOnClickResult = {}));
|
||||
})(PasteButtonOnClickResult || (PasteButtonOnClickResult = {}));
|
||||
|
||||
var SaveIconStyle;
|
||||
(function (SaveIconStyle) {
|
||||
@ -1650,22 +1625,22 @@ var SaveIconStyle;
|
||||
var SaveDescription;
|
||||
(function (SaveDescription) {
|
||||
SaveDescription[SaveDescription["DOWNLOAD"] = 0] = "DOWNLOAD";
|
||||
SaveDescription[SaveDescription["DOWNLOAD_FILES"] = 1] = "DOWNLOAD_FILES";
|
||||
SaveDescription[SaveDescription["DOWNLOAD_FILE"] = 1] = "DOWNLOAD_FILE";
|
||||
SaveDescription[SaveDescription["SAVE"] = 2] = "SAVE";
|
||||
SaveDescription[SaveDescription["SAVE_IMAGES"] = 3] = "SAVE_IMAGES";
|
||||
SaveDescription[SaveDescription["SAVE_FILES"] = 4] = "SAVE_FILES";
|
||||
SaveDescription[SaveDescription["SAVE_IMAGE"] = 3] = "SAVE_IMAGE";
|
||||
SaveDescription[SaveDescription["SAVE_FILE"] = 4] = "SAVE_FILE";
|
||||
SaveDescription[SaveDescription["DOWNLOAD_AND_SHARE"] = 5] = "DOWNLOAD_AND_SHARE";
|
||||
SaveDescription[SaveDescription["RECEIVE"] = 6] = "RECEIVE";
|
||||
SaveDescription[SaveDescription["CONTINUE_TO_RECEIVE"] = 7] = "CONTINUE_TO_RECEIVE";
|
||||
})(SaveDescription || (SaveDescription = {}));
|
||||
|
||||
var SecSaveButtonOnClickResult;
|
||||
(function (SecSaveButtonOnClickResult) {
|
||||
SecSaveButtonOnClickResult[SecSaveButtonOnClickResult["SUCCESS"] = 0] =
|
||||
var SaveButtonOnClickResult;
|
||||
(function (SaveButtonOnClickResult) {
|
||||
SaveButtonOnClickResult[SaveButtonOnClickResult["SUCCESS"] = 0] =
|
||||
"SUCCESS";
|
||||
SecSaveButtonOnClickResult[SecSaveButtonOnClickResult["TEMPORARY_AUTHORIZATION_FAILED"] = 1] =
|
||||
SaveButtonOnClickResult[SaveButtonOnClickResult["TEMPORARY_AUTHORIZATION_FAILED"] = 1] =
|
||||
"TEMPORARY_AUTHORIZATION_FAILED ";
|
||||
})(SecSaveButtonOnClickResult || (SecSaveButtonOnClickResult = {}));
|
||||
})(SaveButtonOnClickResult || (SaveButtonOnClickResult = {}));
|
||||
|
||||
var ObscuredReasons;
|
||||
(function (ObscuredReasons) {
|
||||
|
@ -80,6 +80,7 @@
|
||||
#include "bridge/declarative_frontend/jsview/js_list_item_group.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_loading_progress.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_local_storage.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_location_button.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_marquee.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_matrix2d.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_menu.h"
|
||||
@ -93,6 +94,7 @@
|
||||
#include "bridge/declarative_frontend/jsview/js_offscreen_rendering_context.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_page_transition.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_pan_handler.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_paste_button.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_path.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_path2d.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_pattern_lock.h"
|
||||
@ -112,13 +114,11 @@
|
||||
#include "bridge/declarative_frontend/jsview/js_richeditor.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_row.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_row_split.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_save_button.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_scope_util.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_scroll.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_scroller.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_search.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_sec_location_button.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_sec_paste_button.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_sec_save_button.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_select.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_shape.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_shape_abstract.h"
|
||||
@ -528,9 +528,9 @@ static const std::unordered_map<std::string, std::function<void(BindingTarget)>>
|
||||
{ "AlertDialog", JSAlertDialog::JSBind },
|
||||
{ "ContextMenu", JSContextMenu::JSBind },
|
||||
{ "FormLink", JSFormLink::JSBind },
|
||||
{ "SecLocationButton", JSSecLocationButton::JSBind },
|
||||
{ "SecPasteButton", JSSecPasteButton::JSBind },
|
||||
{ "SecSaveButton", JSSecSaveButton::JSBind },
|
||||
{ "LocationButton", JSLocationButton::JSBind },
|
||||
{ "PasteButton", JSPasteButton::JSBind },
|
||||
{ "SaveButton", JSSaveButton::JSBind },
|
||||
#ifdef ABILITY_COMPONENT_SUPPORTED
|
||||
{ "AbilityComponent", JSAbilityComponent::JSBind },
|
||||
#endif
|
||||
|
@ -1782,6 +1782,30 @@ class stateMgmtTrace {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
class errorReport {
|
||||
static varValueCheckFailed(params) {
|
||||
let msg = `@Component '${params.customComponent}': Illegal variable value error with decorated variable ${params.variableDeco} '${params.variableName}': `;
|
||||
msg += `failed validation: '${params.expectedType}`;
|
||||
try {
|
||||
msg += `, attempt to assign value type: '${typeof params.value}'`;
|
||||
msg += `, value: '${JSON.stringify(params.value, null, 4)}'`;
|
||||
}
|
||||
catch (e) { }
|
||||
msg += "!";
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
static varObservationFailed(params) {
|
||||
let msg = `@Component '${params.customComponent}': decorated variable ${params.variableDeco} '${params.variableName}': `;
|
||||
msg += `its class is neither decorated with '@Observed' nor it is an instance of 'SubscribableAbstract'`;
|
||||
try {
|
||||
msg += `, attempt to assign value type: '${typeof params.value}'`;
|
||||
msg += `, value: '${JSON.stringify(params.value, null, 4)}'`;
|
||||
}
|
||||
catch (e) { }
|
||||
msg += "!";
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -3472,6 +3496,50 @@ class ObservedPropertyAbstractPU extends ObservedPropertyAbstract {
|
||||
numberOfSubscrbers() {
|
||||
return this.subscriberRefs_.size + (this.owningView_ ? 1 : 0);
|
||||
}
|
||||
/*
|
||||
type checking for any supported type, as required for union type support
|
||||
see 1st parameter for explanation what is allowed
|
||||
|
||||
FIXME this expects the Map, Set patch to go in
|
||||
*/
|
||||
checkIsSupportedValue(value) {
|
||||
return this.checkNewValue(`undefined, null, number, boolean, string, or Object but not function`, value, () => ((typeof value == "object" && typeof value != "function")
|
||||
|| typeof value == "number" || typeof value == "string" || typeof value == "boolean")
|
||||
|| (value == undefined || value == null));
|
||||
}
|
||||
/*
|
||||
type checking for allowed Object type value
|
||||
see 1st parameter for explanation what is allowed
|
||||
|
||||
FIXME this expects the Map, Set patch to go in
|
||||
*/
|
||||
checkIsObject(value) {
|
||||
return this.checkNewValue(`undefined, null, Object including Array and instance of SubscribableAbstract and excluding function, Set, and Map`, value, () => (value == undefined || value == null || (typeof value == "object")));
|
||||
}
|
||||
/*
|
||||
type checking for allowed simple types value
|
||||
see 1st parameter for explanation what is allowed
|
||||
*/
|
||||
checkIsSimple(value) {
|
||||
return this.checkNewValue(`undefined, number, boolean, string`, value, () => (value == undefined || typeof value == "number" || typeof value == "string" || typeof value == "boolean"));
|
||||
}
|
||||
checkNewValue(isAllowedComment, newValue, validator) {
|
||||
if (validator(newValue)) {
|
||||
return true;
|
||||
}
|
||||
// report error
|
||||
// current implementation throws an Exception
|
||||
errorReport.varValueCheckFailed({
|
||||
customComponent: this.owningView_ ? this.owningView_.constructor.name : "unknown owningView / internal error",
|
||||
variableDeco: ObservedPropertyAbstractPU.mapDeco.get(this.constructor.name),
|
||||
variableName: this.info(),
|
||||
expectedType: isAllowedComment,
|
||||
value: newValue
|
||||
});
|
||||
// never gets here if errorReport.varValueCheckFailed throws an exception
|
||||
// but should nto depend on its implementation
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* factory function for concrete 'object' or 'simple' ObservedProperty object
|
||||
* depending if value is Class object
|
||||
@ -3542,58 +3610,16 @@ ObservedPropertyAbstractPU.DelayedNotifyChangesEnum = (_a = class {
|
||||
_a.delay_none_pending = 1,
|
||||
_a.delay_notification_pending = 2,
|
||||
_a);
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* ObservedPropertyObjectAbstractPU
|
||||
*
|
||||
* common bbase class of ObservedPropertyObjectPU and
|
||||
* SyncedObjectPropertyTwoWayPU
|
||||
* adds the createObjectLink to the ObservedPropertyAbstract base
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class ObservedPropertyObjectAbstractPU extends ObservedPropertyAbstractPU {
|
||||
constructor(owningView, thisPropertyName) {
|
||||
super(owningView, thisPropertyName);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* ObservedPropertySimpleAbstractPU
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class ObservedPropertySimpleAbstractPU extends ObservedPropertyAbstractPU {
|
||||
constructor(owningView, propertyName) {
|
||||
super(owningView, propertyName);
|
||||
}
|
||||
}
|
||||
ObservedPropertyAbstractPU.mapDeco = new Map([
|
||||
["ObservedPropertyObjectPU", "@State/@Provide"],
|
||||
["ObservedPropertySimplePU", "@State/@Provide (error, should not be used)"],
|
||||
["SynchedPropertyObjectOneWayPU", "@Prop"],
|
||||
["SynchedPropertySimpleOneWayPU", "@Prop (error, should not be used)"],
|
||||
["SynchedPropertyObjectTwoWayPU", "@Link/@Consume"],
|
||||
["SynchedPropertySimpleTwoWayPU", "@Link/@Consume (error, should not be used)"],
|
||||
["SynchedPropertyNestedObjectPU", "@ObjectLink (only class-objects supported"],
|
||||
["SynchedPropertyNesedObjectPU", "@ObjectLink (only class-objects supported"]
|
||||
]);
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -3618,7 +3644,7 @@ class ObservedPropertySimpleAbstractPU extends ObservedPropertyAbstractPU {
|
||||
* uses its base class to manage subscribers to this
|
||||
* property.
|
||||
*/
|
||||
class ObservedPropertyObjectPU extends ObservedPropertyObjectAbstractPU {
|
||||
class ObservedPropertyPU extends ObservedPropertyAbstractPU {
|
||||
constructor(localInitValue, owningView, propertyName) {
|
||||
super(owningView, propertyName);
|
||||
this.setValueInternal(localInitValue);
|
||||
@ -3665,21 +3691,20 @@ class ObservedPropertyObjectPU extends ObservedPropertyObjectAbstractPU {
|
||||
and also notify with this.aboutToChange();
|
||||
*/
|
||||
setValueInternal(newValue) {
|
||||
if (newValue == undefined || newValue == null) {
|
||||
stateMgmtConsole.error(`ObservedPropertyObjectPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @State/@Provide value must not be undefined or null. Application error!`);
|
||||
// TODO enable support for undefined and null
|
||||
// unsubscribe old value, set wrappedValue_ to null/undefined
|
||||
}
|
||||
if (typeof newValue !== 'object') {
|
||||
|
||||
return false;
|
||||
}
|
||||
if (newValue == this.wrappedValue_) {
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!this.checkIsSupportedValue(newValue)) {
|
||||
return false;
|
||||
}
|
||||
this.unsubscribeWrappedObject();
|
||||
if (newValue instanceof SubscribableAbstract) {
|
||||
if (!newValue || typeof newValue !== 'object') {
|
||||
// undefined, null, simple type:
|
||||
// nothing to subscribe to in case of new value undefined || null || simple type
|
||||
this.wrappedValue_ = newValue;
|
||||
}
|
||||
else if (newValue instanceof SubscribableAbstract) {
|
||||
|
||||
this.wrappedValue_ = newValue;
|
||||
this.wrappedValue_.addOwningProperty(this);
|
||||
@ -3716,84 +3741,10 @@ class ObservedPropertyObjectPU extends ObservedPropertyObjectAbstractPU {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* ObservedPropertySimplePU
|
||||
* implementation of @State and @Provide decorated variables of types (T=) boolean | number | string | enum
|
||||
*
|
||||
* Holds an actual property value of type T
|
||||
* uses its base class to manage subscribers to this
|
||||
* property.
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class ObservedPropertySimplePU extends ObservedPropertySimpleAbstractPU {
|
||||
constructor(localInitValue, owningView, propertyName) {
|
||||
super(owningView, propertyName);
|
||||
// TODO undefined and null support remove this if statement
|
||||
if (typeof localInitValue === "object") {
|
||||
throw new SyntaxError("ObservedPropertySimple constructor: @State/@Provide value must not be an object");
|
||||
}
|
||||
this.setValueInternal(localInitValue);
|
||||
}
|
||||
aboutToBeDeleted(unsubscribeMe) {
|
||||
this.removeSubscriber(unsubscribeMe);
|
||||
super.aboutToBeDeleted();
|
||||
}
|
||||
/**
|
||||
* Called by a @Link - SynchedPropertySimpleTwoWay that uses this as sync peer when it has changed
|
||||
* @param eventSource
|
||||
*/
|
||||
syncPeerHasChanged(eventSource) {
|
||||
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
/*
|
||||
actually update this.wrappedValue_
|
||||
called needs to do value change check
|
||||
and also notify with this.aboutToChange();
|
||||
*/
|
||||
setValueInternal(newValue) {
|
||||
|
||||
if (this.wrappedValue_ != newValue) {
|
||||
this.wrappedValue_ = newValue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
getUnmonitored() {
|
||||
|
||||
// unmonitored get access , no call to notifyPropertyRead !
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
get() {
|
||||
|
||||
this.notifyPropertyHasBeenReadPU();
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
set(newValue) {
|
||||
if (this.wrappedValue_ == newValue) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.setValueInternal(newValue)) {
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
// class definitions for backward compatibility
|
||||
class ObservedPropertyObjectPU extends ObservedPropertyPU {
|
||||
}
|
||||
class ObservedPropertySimplePU extends ObservedPropertyPU {
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
@ -3840,22 +3791,22 @@ class ObservedPropertySimplePU extends ObservedPropertySimpleAbstractPU {
|
||||
*
|
||||
* 1- assignment of a new Object value: this.aProp = new ClassA()
|
||||
* rhs can be ObservedObject because of @Observed decoration or now
|
||||
* notifyPropertryHasChangedPU
|
||||
* notifyPropertyHasChangedPU
|
||||
*
|
||||
* 2- local ObservedObject member property change
|
||||
* objectPropertyHasChangedPU called, eventSource is the ObservedObject stored in localCopyObservedObject_
|
||||
* no need to copy, notifyPropertryHasChangedPU
|
||||
* no need to copy, notifyPropertyHasChangedPU
|
||||
*
|
||||
* 3- Rerender of the custom component triggered from the parent
|
||||
* reset() is called (code generated by the transpiler), set the value of source_ , if that causes a change will call syncPeerHasChanged
|
||||
* syncPeerHasChanged need to deep copy the ObservedObject from source to localCopyObservedObject_
|
||||
* notifyPropertryHasChangedPU
|
||||
* notifyPropertyHasChangedPU
|
||||
*
|
||||
* 4- source_ ObservedObject member property change
|
||||
* objectPropertyHasChangedPU called, eventSource is the ObservedObject stored source_.getUnmonitored
|
||||
* notifyPropertryHasChangedPU
|
||||
* notifyPropertyHasChangedPU
|
||||
*/
|
||||
class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
class SynchedPropertyOneWayPU extends ObservedPropertyAbstractPU {
|
||||
constructor(source, owningChildView, thisPropertyName) {
|
||||
super(owningChildView, thisPropertyName);
|
||||
if (source && (typeof (source) === "object") && ("subscribeMe" in source)) {
|
||||
@ -3866,16 +3817,19 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
this.source_.addSubscriber(this);
|
||||
}
|
||||
else {
|
||||
// code path for
|
||||
// 1- source is of same type C in parent, source is its value, not the backing store ObservedPropertyObject
|
||||
// 2- nested Object/Array inside observed another object/array in parent, source is its value
|
||||
if (!((source instanceof SubscribableAbstract) || ObservedObject.IsObservedObject(source))) {
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Provided source object's class
|
||||
lacks @Observed class decorator. Object property changes will not be observed.`);
|
||||
const sourceValue = source;
|
||||
if (this.checkIsSupportedValue(sourceValue)) {
|
||||
// code path for
|
||||
// 1- source is of same type C in parent, source is its value, not the backing store ObservedPropertyObject
|
||||
// 2- nested Object/Array inside observed another object/array in parent, source is its value
|
||||
if (!((sourceValue instanceof SubscribableAbstract) || ObservedObject.IsObservedObject(sourceValue))) {
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Provided source object's class is not instance of SubscribableAbstract,
|
||||
it also lacks @Observed class decorator. Object property changes will not be observed.`);
|
||||
}
|
||||
|
||||
this.source_ = new ObservedPropertyObjectPU(sourceValue, this, this.getSourceObservedPropertyFakeName());
|
||||
this.sourceIsOwnObject = true;
|
||||
}
|
||||
|
||||
this.source_ = new ObservedPropertyObjectPU(source, this, this.getSourceObservedPropertyFakeName());
|
||||
this.sourceIsOwnObject = true;
|
||||
}
|
||||
if (this.source_ != undefined) {
|
||||
this.resetLocalValue(this.source_.get(), /* needCopyObject */ true);
|
||||
@ -3901,11 +3855,16 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
return `${this.info()}_source`;
|
||||
}
|
||||
syncPeerHasChanged(eventSource) {
|
||||
if (this.source_ == undefined) {
|
||||
stateMgmtConsole.error(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: \
|
||||
@Prop syncPeerHasChanged peer '${eventSource ? eventSource.info() : "no eventSource info"}' but source_ undefned. Internal error.`);
|
||||
return;
|
||||
}
|
||||
if (eventSource && this.source_ == eventSource) {
|
||||
// defensive programming: should always be the case!
|
||||
|
||||
const newValue = this.source_.getUnmonitored();
|
||||
if (typeof newValue == "object") {
|
||||
if (this.checkIsSupportedValue(newValue)) {
|
||||
|
||||
if (this.resetLocalValue(newValue, /* needCopyObject */ true)) {
|
||||
this.notifyPropertyHasChangedPU();
|
||||
@ -3913,7 +3872,7 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
}
|
||||
}
|
||||
else {
|
||||
stateMgmtConsole.warn(`SynchedPropertyObjectOneWayPU[${this.id__()}]: syncPeerHasChanged Unexpected situation. Ignoring event.`);
|
||||
stateMgmtConsole.warn(`SynchedPropertyObjectOneWayPU[${this.id__()}]: syncPeerHasChanged Unexpected situation. syncPeerHasChanged from different sender than source_. Ignoring event.`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -3947,10 +3906,6 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ObservedObject.IsObservedObject(newValue)) {
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Set: Provided new object's class
|
||||
lacks '@Observed' class decorator. Object property changes will not be observed.`);
|
||||
}
|
||||
if (this.resetLocalValue(newValue, /* needCopyObject */ false)) {
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
@ -3958,13 +3913,10 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
// called when updated from parent
|
||||
reset(sourceChangedValue) {
|
||||
|
||||
if (this.source_ !== undefined) {
|
||||
if (this.source_ !== undefined && this.checkIsSupportedValue(sourceChangedValue)) {
|
||||
// if this.source_.set causes an actual change, then, ObservedPropertyObject source_ will call syncPeerHasChanged method
|
||||
this.source_.set(sourceChangedValue);
|
||||
}
|
||||
else {
|
||||
stateMgmtConsole.error(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: reset @Prop --- No source_. Internal error!`);
|
||||
}
|
||||
}
|
||||
/*
|
||||
unsubscribe from previous wrapped ObjectObject
|
||||
@ -3976,9 +3928,8 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
resetLocalValue(newObservedObjectValue, needCopyObject) {
|
||||
// note: We can not test for newObservedObjectValue == this.localCopyObservedObject_
|
||||
// here because the object might still be the same, but some property of it has changed
|
||||
if (typeof newObservedObjectValue !== "object") {
|
||||
// if not undefined or null, then the provided newObservedObjectValue must be an Object
|
||||
stateMgmtConsole.error(`SynchedPropertyOneWayObjectPU[${this.id__()}]: setLocalValue new value must be an Object.`);
|
||||
if (!this.checkIsSupportedValue(newObservedObjectValue)) {
|
||||
return;
|
||||
}
|
||||
// unsubscribe from old local copy
|
||||
if (this.localCopyObservedObject_ instanceof SubscribableAbstract) {
|
||||
@ -3990,24 +3941,24 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
// shallow/deep copy value
|
||||
// needed whenever newObservedObjectValue comes from source
|
||||
// not needed on a local set (aka when called from set() method)
|
||||
let copy = needCopyObject ? this.copyObject(newObservedObjectValue, this.info_) : newObservedObjectValue;
|
||||
if (copy instanceof SubscribableAbstract) {
|
||||
this.localCopyObservedObject_ = copy;
|
||||
// deep copy will copy Set of subscribers as well. But local copy only has its own subscribers
|
||||
// not those of its parent value.
|
||||
this.localCopyObservedObject_.clearOwningProperties();
|
||||
this.localCopyObservedObject_.addOwningProperty(this);
|
||||
}
|
||||
else if (ObservedObject.IsObservedObject(copy)) {
|
||||
// case: new ObservedObject
|
||||
this.localCopyObservedObject_ = copy;
|
||||
ObservedObject.addOwningProperty(this.localCopyObservedObject_, this);
|
||||
}
|
||||
else {
|
||||
// wrap newObservedObjectValue raw object as ObservedObject and subscribe to it
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Provided source object's class \
|
||||
this.localCopyObservedObject_ = needCopyObject ? this.copyObject(newObservedObjectValue, this.info_) : newObservedObjectValue;
|
||||
if (typeof this.localCopyObservedObject_ == "object") {
|
||||
if (this.localCopyObservedObject_ instanceof SubscribableAbstract) {
|
||||
// deep copy will copy Set of subscribers as well. But local copy only has its own subscribers
|
||||
// not those of its parent value.
|
||||
this.localCopyObservedObject_.clearOwningProperties();
|
||||
this.localCopyObservedObject_.addOwningProperty(this);
|
||||
}
|
||||
else if (ObservedObject.IsObservedObject(this.localCopyObservedObject_)) {
|
||||
// case: new ObservedObject
|
||||
ObservedObject.addOwningProperty(this.localCopyObservedObject_, this);
|
||||
}
|
||||
else {
|
||||
// wrap newObservedObjectValue raw object as ObservedObject and subscribe to it
|
||||
stateMgmtConsole.error(`@Prop ${this.info()} Provided source object's class \
|
||||
lacks @Observed class decorator. Object property changes will not be observed.`);
|
||||
this.localCopyObservedObject_ = ObservedObject.createNew(copy, this);
|
||||
this.localCopyObservedObject_ = ObservedObject.createNew(this.localCopyObservedObject_, this);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -4025,11 +3976,11 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
shallowCopyObject(value, propName) {
|
||||
let rawValue = ObservedObject.GetRawObject(value);
|
||||
let copy;
|
||||
if (rawValue == undefined || rawValue == null) {
|
||||
if (!rawValue || typeof rawValue !== 'object') {
|
||||
copy = rawValue;
|
||||
}
|
||||
else if (typeof rawValue != "object") {
|
||||
// TODO would it be better to crash the app here?
|
||||
// FIXME would it be better to throw Exception here?
|
||||
stateMgmtConsole.error(`@Prop ${this.info()} shallowCopyObject: request to copy non-object but defined value of type '${typeof rawValue}'. Internal error! Setting copy=original value.`);
|
||||
copy = rawValue;
|
||||
}
|
||||
@ -4137,6 +4088,11 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
}
|
||||
}
|
||||
}
|
||||
// class definitions for backward compatibility
|
||||
class SynchedPropertySimpleOneWayPU extends SynchedPropertyOneWayPU {
|
||||
}
|
||||
class SynchedPropertyObjectOneWayPU extends SynchedPropertyOneWayPU {
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -4156,8 +4112,8 @@ class SynchedPropertyObjectOneWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
* implementation of @Link and @Consume decorated variables of type class object
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class SynchedPropertyObjectTwoWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
*/
|
||||
class SynchedPropertyTwoWayPU extends ObservedPropertyAbstractPU {
|
||||
constructor(source, owningChildView, thisPropertyName) {
|
||||
super(owningChildView, thisPropertyName);
|
||||
this.changeNotificationIsOngoing_ = false;
|
||||
@ -4169,7 +4125,7 @@ class SynchedPropertyObjectTwoWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
ObservedObject.addOwningProperty(this.source_.get(), this);
|
||||
}
|
||||
else {
|
||||
stateMgmtConsole.error(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Link/@Consume source must not be undefined. Application error!`);
|
||||
throw new SyntaxError(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Link/@Consume source variable in parent/ancestor @ Component must be defined. Application error!`);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -4190,20 +4146,23 @@ class SynchedPropertyObjectTwoWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
}
|
||||
setObject(newValue) {
|
||||
if (!this.source_) {
|
||||
stateMgmtConsole.warn(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: setObject (assign a new value), @Link/@Consume: no linked parent property. Likely a consequence of earlier application error.`);
|
||||
throw new SyntaxError(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: setObject (assign a new value), \
|
||||
@Link/@Consume: no source variable in parent/ancestor @Component. Application error.`);
|
||||
}
|
||||
if (this.getUnmonitored() == newValue) {
|
||||
|
||||
return;
|
||||
}
|
||||
let oldValueObject = this.getUnmonitored();
|
||||
if (oldValueObject != undefined && oldValueObject != null) {
|
||||
ObservedObject.removeOwningProperty(oldValueObject, this);
|
||||
|
||||
if (this.checkIsSupportedValue(newValue)) {
|
||||
// the source_ ObservedProperty will call: this.syncPeerHasChanged(newValue);
|
||||
this.source_.set(newValue);
|
||||
}
|
||||
this.source_.set(newValue);
|
||||
ObservedObject.addOwningProperty(this.getUnmonitored(), this);
|
||||
}
|
||||
/**
|
||||
* Called when sync peer ObservedPropertyObject or SynchedPropertyObjectTwoWay has chnaged value
|
||||
* Called when sync peer ObservedPropertyObject or SynchedPropertyObjectTwoWay has changed value
|
||||
* that peer can be in either parent or child component if 'this' is used for a @Link
|
||||
* that peer can be in either acestor or descendant component if 'this' is used for a @Consume
|
||||
* that peer can be in either ancestor or descendant component if 'this' is used for a @Consume
|
||||
* @param eventSource
|
||||
*/
|
||||
syncPeerHasChanged(eventSource) {
|
||||
@ -4217,11 +4176,11 @@ class SynchedPropertyObjectTwoWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
* @param souceObject
|
||||
* @param changedPropertyName
|
||||
*/
|
||||
objectPropertyHasChangedPU(souceObject, changedPropertyName) {
|
||||
objectPropertyHasChangedPU(sourceObject, changedPropertyName) {
|
||||
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
objectPropertyHasBeenReadPU(souceObject, changedPropertyName) {
|
||||
objectPropertyHasBeenReadPU(sourceObject, changedPropertyName) {
|
||||
|
||||
this.notifyPropertyHasBeenReadPU();
|
||||
}
|
||||
@ -4250,185 +4209,10 @@ class SynchedPropertyObjectTwoWayPU extends ObservedPropertyObjectAbstractPU {
|
||||
this.changeNotificationIsOngoing_ = false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* SynchedPropertySimpleOneWayPU
|
||||
* implementation of @Prop decorated variable of types boolean | number | string | enum
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class SynchedPropertySimpleOneWayPU extends ObservedPropertySimpleAbstractPU {
|
||||
constructor(source, subscribeMe, thisPropertyName) {
|
||||
super(subscribeMe, thisPropertyName);
|
||||
// Check that source is ObservedPropertyAbstruct
|
||||
if (source && (typeof (source) === "object") && ("notifyHasChanged" in source) && ("subscribeMe" in source)) {
|
||||
// code path for @(Local)StorageProp
|
||||
this.source_ = source;
|
||||
this.sourceIsOwnObject = false;
|
||||
this.source_.addSubscriber(this);
|
||||
// subscribe to receive value change updates from LocalStorage source property
|
||||
}
|
||||
else {
|
||||
// code path for @Prop
|
||||
this.source_ = new ObservedPropertySimplePU(source, this, thisPropertyName);
|
||||
this.sourceIsOwnObject = true;
|
||||
}
|
||||
// use own backing store for value to avoid
|
||||
// value changes to be propagated back to source
|
||||
this.wrappedValue_ = this.source_.getUnmonitored();
|
||||
}
|
||||
/*
|
||||
like a destructor, need to call this before deleting
|
||||
the property.
|
||||
*/
|
||||
aboutToBeDeleted() {
|
||||
if (this.source_) {
|
||||
this.source_.removeSubscriber(this);
|
||||
if (this.sourceIsOwnObject == true && this.source_.numberOfSubscrbers() == 0) {
|
||||
|
||||
this.source_.aboutToBeDeleted();
|
||||
}
|
||||
this.source_ = undefined;
|
||||
this.sourceIsOwnObject = false;
|
||||
}
|
||||
super.aboutToBeDeleted();
|
||||
}
|
||||
syncPeerHasChanged(eventSource) {
|
||||
if (eventSource && (eventSource == this.source_)) {
|
||||
// defensive, should always be the case
|
||||
|
||||
this.setWrappedValue(eventSource.getUnmonitored());
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
getUnmonitored() {
|
||||
|
||||
// unmonitored get access, no call to notifyPropertyRead !
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
// get 'read through` from the ObservedProperty
|
||||
get() {
|
||||
|
||||
this.notifyPropertyHasBeenReadPU();
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
set(newValue) {
|
||||
if (this.wrappedValue_ == newValue) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.setWrappedValue(newValue);
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
reset(sourceChangedValue) {
|
||||
|
||||
// if set causes an actual change, then, ObservedPropertySimple source_ will call hasChanged
|
||||
if (this.source_ !== undefined) {
|
||||
// if set causes an actual change, then, ObservedPropertySimple source_ will call hasChanged
|
||||
this.source_.set(sourceChangedValue);
|
||||
}
|
||||
}
|
||||
setWrappedValue(newValue) {
|
||||
this.wrappedValue_ = newValue;
|
||||
}
|
||||
// class definitions for backward compatibility
|
||||
class SynchedPropertyObjectTwoWayPU extends SynchedPropertyTwoWayPU {
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* SynchedPropertySimpleTwoWayPU
|
||||
* implementation of @Link and @Consume decorated variables of types boolean | number | string | enum
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class SynchedPropertySimpleTwoWayPU extends ObservedPropertySimpleAbstractPU {
|
||||
constructor(source, owningView, owningViewPropNme) {
|
||||
super(owningView, owningViewPropNme);
|
||||
this.changeNotificationIsOngoing_ = false;
|
||||
this.source_ = source;
|
||||
if (this.source_) {
|
||||
this.source_.addSubscriber(this);
|
||||
}
|
||||
else {
|
||||
stateMgmtConsole.error(`SynchedPropertySimpleTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Link/@Consume source must not be undefined. Application error!`);
|
||||
}
|
||||
}
|
||||
/*
|
||||
like a destructor, need to call this before deleting
|
||||
the property.
|
||||
*/
|
||||
aboutToBeDeleted() {
|
||||
if (this.source_) {
|
||||
this.source_.removeSubscriber(this);
|
||||
this.source_ = undefined;
|
||||
}
|
||||
super.aboutToBeDeleted();
|
||||
}
|
||||
/**
|
||||
* Called when sync peer ObservedPropertySimple or SynchedPropertySimpletTwoWay has chnaged value
|
||||
* that peer can be in either parent or child component if 'this' is used for a @Link
|
||||
* that peer can be in either acestor or descendant component if 'this' is used for a @Consume
|
||||
* @param eventSource
|
||||
*/
|
||||
syncPeerHasChanged(eventSource) {
|
||||
if (!this.changeNotificationIsOngoing_) {
|
||||
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
getUnmonitored() {
|
||||
|
||||
return (this.source_ ? this.source_.getUnmonitored() : undefined);
|
||||
}
|
||||
// get 'read through` from the ObservedProperty
|
||||
get() {
|
||||
|
||||
this.notifyPropertyHasBeenReadPU();
|
||||
return this.getUnmonitored();
|
||||
}
|
||||
// set 'writes through` to the ObservedProperty
|
||||
set(newValue) {
|
||||
if (!this.source_) {
|
||||
|
||||
return;
|
||||
}
|
||||
if (this.source_.get() == newValue) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// avoid circular notifications @Link -> source @State -> other but also to same @Link
|
||||
this.changeNotificationIsOngoing_ = true;
|
||||
// the source_ ObservedProeprty will call: this.hasChanged(newValue);
|
||||
this.source_.set(newValue);
|
||||
this.notifyPropertyHasChangedPU();
|
||||
this.changeNotificationIsOngoing_ = false;
|
||||
}
|
||||
class SynchedPropertySimpleTwoWayPU extends SynchedPropertyTwoWayPU {
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
@ -4451,7 +4235,7 @@ class SynchedPropertySimpleTwoWayPU extends ObservedPropertySimpleAbstractPU {
|
||||
* all definitions in this file are framework internal
|
||||
*
|
||||
*/
|
||||
class SynchedPropertyNestedObjectPU extends ObservedPropertyObjectAbstractPU {
|
||||
class SynchedPropertyNestedObjectPU extends ObservedPropertyAbstractPU {
|
||||
/**
|
||||
* Construct a Property of a su component that links to a variable of parent view that holds an ObservedObject
|
||||
* example
|
||||
@ -4501,11 +4285,15 @@ class SynchedPropertyNestedObjectPU extends ObservedPropertyObjectAbstractPU {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setValueInternal(newValue);
|
||||
// notify value change to subscribing View
|
||||
this.notifyPropertyHasChangedPU();
|
||||
if (this.setValueInternal(newValue)) {
|
||||
// notify value change to subscribing View
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
setValueInternal(newValue) {
|
||||
if (!this.checkIsObject(newValue)) {
|
||||
return false;
|
||||
}
|
||||
if (this.obsObject_ != undefined) {
|
||||
if (this.obsObject_ instanceof SubscribableAbstract) {
|
||||
// unregister from SubscribableAbstract object
|
||||
@ -4531,6 +4319,7 @@ class SynchedPropertyNestedObjectPU extends ObservedPropertyObjectAbstractPU {
|
||||
value changes will bot be observed and UI will not update. forgot @Observed class decorator? Application error.`);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/** backward compatibility after typo in classname fix */
|
||||
@ -4938,26 +4727,31 @@ class ViewPU extends NativeViewPartialUpdate {
|
||||
/**
|
||||
* Method for the sub-class to call from its constructor for resolving
|
||||
* a @Consume variable and initializing its backing store
|
||||
* with the yncedPropertyTwoWay<T> object created from the
|
||||
* with the SyncedPropertyTwoWay<T> object created from the
|
||||
* @Provide variable's backing store.
|
||||
* @param providedPropName the name of the @Provide'd variable.
|
||||
* This is either the @Consume decortor parameter, or variable name.
|
||||
* This is either the @Consume decorator parameter, or variable name.
|
||||
* @param consumeVarName the @Consume variable name (not the
|
||||
* @Consume decortor parameter)
|
||||
* @returns initiaizing value of the @Consume backing store
|
||||
* @Consume decorator parameter)
|
||||
* @returns initializing value of the @Consume backing store
|
||||
*/
|
||||
initializeConsume(providedPropName, consumeVarName) {
|
||||
let providedVarStore = this.providedVars_.get(providedPropName);
|
||||
if (providedVarStore === undefined) {
|
||||
throw new ReferenceError(`${this.constructor.name}: missing @Provide property with name ${providedPropName}.
|
||||
Fail to resolve @Consume(${providedPropName}).`);
|
||||
Fail to resolve @Consume(${providedPropName}).`);
|
||||
}
|
||||
return providedVarStore.createSync((source) => (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleTwoWayPU(source, this, consumeVarName)
|
||||
: new SynchedPropertyObjectTwoWayPU(source, this, consumeVarName));
|
||||
const factory = (source) => {
|
||||
const result = ((source instanceof ObservedPropertySimple) || (source instanceof ObservedPropertySimplePU))
|
||||
? new SynchedPropertyObjectTwoWayPU(source, this, consumeVarName)
|
||||
: new SynchedPropertyObjectTwoWayPU(source, this, consumeVarName);
|
||||
stateMgmtConsole.error(`The @Consume is instance of ${result.constructor.name}`);
|
||||
return result;
|
||||
};
|
||||
return providedVarStore.createSync(factory);
|
||||
}
|
||||
/**
|
||||
* given the elmtid of a child or child of child within this custom component
|
||||
* given the elmtId of a child or child of child within this custom component
|
||||
* remember this component needs a partial update
|
||||
* @param elmtId
|
||||
*/
|
||||
@ -5186,7 +4980,7 @@ class ViewPU extends NativeViewPartialUpdate {
|
||||
const appStorageLink = AppStorage.__createSync(storagePropName, defaultValue, (source) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleTwoWayPU(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectTwoWayPU(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectTwoWayPU(source, this, viewVariableName));
|
||||
this.ownStorageLinksProps_.add(appStorageLink);
|
||||
return appStorageLink;
|
||||
@ -5195,7 +4989,7 @@ class ViewPU extends NativeViewPartialUpdate {
|
||||
const appStorageProp = AppStorage.__createSync(storagePropName, defaultValue, (source) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleOneWayPU(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectOneWayPU(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectOneWayPU(source, this, viewVariableName));
|
||||
this.ownStorageLinksProps_.add(appStorageProp);
|
||||
return appStorageProp;
|
||||
@ -5204,7 +4998,7 @@ class ViewPU extends NativeViewPartialUpdate {
|
||||
const localStorageLink = this.localStorage_.__createSync(storagePropName, defaultValue, (source) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleTwoWayPU(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectTwoWayPU(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectTwoWayPU(source, this, viewVariableName));
|
||||
this.ownStorageLinksProps_.add(localStorageLink);
|
||||
return localStorageLink;
|
||||
@ -5213,7 +5007,7 @@ class ViewPU extends NativeViewPartialUpdate {
|
||||
const localStorageProp = this.localStorage_.__createSync(storagePropName, defaultValue, (source) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleOneWayPU(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectOneWayPU(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectOneWayPU(source, this, viewVariableName));
|
||||
this.ownStorageLinksProps_.add(localStorageProp);
|
||||
return localStorageProp;
|
||||
|
@ -68,14 +68,14 @@ void JSCustomDialogController::ConstructorCallback(const JSCallbackInfo& info)
|
||||
|
||||
// check if owner object is set
|
||||
JSView* ownerView = ownerObj->Unwrap<JSView>();
|
||||
auto instance = new JSCustomDialogController(ownerView);
|
||||
if (ownerView == nullptr) {
|
||||
info.SetReturnValue(instance);
|
||||
instance = nullptr;
|
||||
LOGE("JSCustomDialogController creation with invalid arguments. Missing \'ownerView\'");
|
||||
return;
|
||||
}
|
||||
|
||||
auto instance = new JSCustomDialogController(ownerView);
|
||||
instance->ownerView_ = ownerView;
|
||||
|
||||
// Process builder function.
|
||||
JSRef<JSVal> builderCallback = constructorArg->GetProperty("builder");
|
||||
if (!builderCallback->IsUndefined() && builderCallback->IsFunction()) {
|
||||
@ -176,10 +176,6 @@ void JSCustomDialogController::ConstructorCallback(const JSCallbackInfo& info)
|
||||
instance->dialogProperties_.isShowInSubWindow = showInSubWindowValue->ToBoolean();
|
||||
#endif
|
||||
}
|
||||
auto container = Container::Current();
|
||||
if (container && container->IsScenceBoardWindow()) {
|
||||
instance->dialogProperties_.isShowInSubWindow = false;
|
||||
}
|
||||
|
||||
info.SetReturnValue(instance);
|
||||
} else {
|
||||
@ -203,6 +199,10 @@ void JSCustomDialogController::JsOpenDialog(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->ownerView_ == nullptr) {
|
||||
LOGE("JSCustomDialogController(JsOpenDialog) Missing \'ownerView\'");
|
||||
return;
|
||||
}
|
||||
auto containerId = this->ownerView_->GetInstanceId();
|
||||
ContainerScope containerScope(containerId);
|
||||
|
||||
@ -251,6 +251,10 @@ void JSCustomDialogController::JsCloseDialog(const JSCallbackInfo& info)
|
||||
{
|
||||
LOGI("JSCustomDialogController(JsCloseDialog)");
|
||||
|
||||
if (this->ownerView_ == nullptr) {
|
||||
LOGE("JSCustomDialogController(JsCloseDialog) Missing \'ownerView\'");
|
||||
return;
|
||||
}
|
||||
auto containerId = this->ownerView_->GetInstanceId();
|
||||
ContainerScope containerScope(containerId);
|
||||
|
||||
|
@ -147,6 +147,41 @@ JSRef<JSVal> DatePickerChangeEventToJSValue(const DatePickerChangeEvent& eventIn
|
||||
}
|
||||
return JSRef<JSVal>::Cast(obj);
|
||||
}
|
||||
|
||||
JSRef<JSVal> DatePickerDateChangeEventToJSValue(const DatePickerChangeEvent& eventInfo)
|
||||
{
|
||||
JSRef<JSObject> obj = JSRef<JSObject>::New();
|
||||
std::unique_ptr<JsonValue> argsPtr = JsonUtil::ParseJsonString(eventInfo.GetSelectedStr());
|
||||
if (!argsPtr) {
|
||||
LOGW("selectedStr is not exist.");
|
||||
return JSRef<JSVal>::Cast(obj);
|
||||
}
|
||||
std::tm dateTime = { 0 };
|
||||
auto year = argsPtr->GetValue("year");
|
||||
if (year && year->IsNumber()) {
|
||||
dateTime.tm_year = year->GetInt() - 1900; // local date start from 1900
|
||||
}
|
||||
auto month = argsPtr->GetValue("month");
|
||||
if (month && month->IsNumber()) {
|
||||
dateTime.tm_mon = month->GetInt();
|
||||
}
|
||||
auto day = argsPtr->GetValue("day");
|
||||
if (day && day->IsNumber()) {
|
||||
dateTime.tm_mday = day->GetInt();
|
||||
}
|
||||
auto hour = argsPtr->GetValue("hour");
|
||||
if (hour && hour->IsNumber()) {
|
||||
dateTime.tm_hour = hour->GetInt();
|
||||
}
|
||||
auto minute = argsPtr->GetValue("minute");
|
||||
if (minute && minute->IsNumber()) {
|
||||
dateTime.tm_min = minute->GetInt();
|
||||
}
|
||||
|
||||
auto milliseconds = Date::GetMilliSecondsByDateTime(dateTime);
|
||||
auto dateObj = JSDate::New(milliseconds);
|
||||
return JSRef<JSVal>::Cast(dateObj);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void JSDatePicker::JSBind(BindingTarget globalObj)
|
||||
@ -156,6 +191,7 @@ void JSDatePicker::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSDatePicker>::StaticMethod("create", &JSDatePicker::Create, opt);
|
||||
JSClass<JSDatePicker>::StaticMethod("lunar", &JSDatePicker::SetLunar);
|
||||
JSClass<JSDatePicker>::StaticMethod("onChange", &JSDatePicker::OnChange);
|
||||
JSClass<JSDatePicker>::StaticMethod("onDateChange", &JSDatePicker::OnDateChange);
|
||||
JSClass<JSDatePicker>::StaticMethod("backgroundColor", &JSDatePicker::PickerBackgroundColor);
|
||||
// keep compatible, need remove after
|
||||
JSClass<JSDatePicker>::StaticMethod("useMilitaryTime", &JSDatePicker::UseMilitaryTime);
|
||||
@ -233,19 +269,21 @@ void JSDatePicker::ParseTextProperties(const JSRef<JSObject>& paramObj, NG::Pick
|
||||
void JSDatePicker::ParseTextStyle(const JSRef<JSObject>& paramObj, NG::PickerTextStyle& textStyle)
|
||||
{
|
||||
auto fontColor = paramObj->GetProperty("color");
|
||||
auto fontStyle = paramObj->GetProperty("font");
|
||||
auto fontOptions = paramObj->GetProperty("font");
|
||||
|
||||
Color textColor;
|
||||
if (JSViewAbstract::ParseJsColor(fontColor, textColor)) {
|
||||
textStyle.textColor = textColor;
|
||||
}
|
||||
|
||||
if (!fontStyle->IsObject()) {
|
||||
if (!fontOptions->IsObject()) {
|
||||
return;
|
||||
}
|
||||
JSRef<JSObject> fontObj = JSRef<JSObject>::Cast(fontStyle);
|
||||
JSRef<JSObject> fontObj = JSRef<JSObject>::Cast(fontOptions);
|
||||
auto fontSize = fontObj->GetProperty("size");
|
||||
auto fontWeight = fontObj->GetProperty("weight");
|
||||
auto fontFamily = fontObj->GetProperty("family");
|
||||
auto fontStyle = fontObj->GetProperty("style");
|
||||
if (fontSize->IsNull() || fontSize->IsUndefined()) {
|
||||
textStyle.fontSize = Dimension(-1);
|
||||
} else {
|
||||
@ -267,6 +305,22 @@ void JSDatePicker::ParseTextStyle(const JSRef<JSObject>& paramObj, NG::PickerTex
|
||||
}
|
||||
textStyle.fontWeight = ConvertStrToFontWeight(weight);
|
||||
}
|
||||
|
||||
if (!fontFamily->IsNull() && !fontFamily->IsUndefined()) {
|
||||
std::vector<std::string> families;
|
||||
if (ParseJsFontFamilies(fontFamily, families)) {
|
||||
textStyle.fontFamily = families;
|
||||
}
|
||||
}
|
||||
|
||||
if (fontStyle->IsNumber()) {
|
||||
auto style = fontStyle->ToNumber<int32_t>();
|
||||
if (style < 0 || style > 1) {
|
||||
LOGE("Text fontStyle(%d) is invalid value", style);
|
||||
return;
|
||||
}
|
||||
textStyle.fontStyle = static_cast<FontStyle>(style);
|
||||
}
|
||||
}
|
||||
|
||||
void JSDatePicker::SetDisappearTextStyle(const JSCallbackInfo& info)
|
||||
@ -335,6 +389,23 @@ void JSDatePicker::OnChange(const JSCallbackInfo& info)
|
||||
DatePickerModel::GetInstance()->SetOnChange(std::move(onChange));
|
||||
}
|
||||
|
||||
void JSDatePicker::OnDateChange(const JSCallbackInfo& info)
|
||||
{
|
||||
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
||||
LOGI("info not function");
|
||||
return;
|
||||
}
|
||||
auto jsFunc = AceType::MakeRefPtr<JsEventFunction<DatePickerChangeEvent, 1>>(
|
||||
JSRef<JSFunc>::Cast(info[0]), DatePickerDateChangeEventToJSValue);
|
||||
auto onDateChange = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc)](const BaseEventInfo* info) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("datePicker.onDateChange");
|
||||
const auto* eventInfo = TypeInfoHelper::DynamicCast<DatePickerChangeEvent>(info);
|
||||
func->Execute(*eventInfo);
|
||||
};
|
||||
DatePickerModel::GetInstance()->SetOnDateChange(std::move(onDateChange));
|
||||
}
|
||||
|
||||
void JSTimePicker::OnChange(const JSCallbackInfo& info)
|
||||
{
|
||||
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
||||
@ -602,6 +673,8 @@ void JSDatePickerDialog::Show(const JSCallbackInfo& info)
|
||||
std::function<void()> cancelEvent;
|
||||
std::function<void(const std::string&)> acceptEvent;
|
||||
std::function<void(const std::string&)> changeEvent;
|
||||
std::function<void(const std::string&)> dateChangeEvent;
|
||||
std::function<void(const std::string&)> dateAcceptEvent;
|
||||
auto onChange = paramObject->GetProperty("onChange");
|
||||
if (!onChange->IsUndefined() && onChange->IsFunction()) {
|
||||
auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(onChange));
|
||||
@ -633,6 +706,82 @@ void JSDatePickerDialog::Show(const JSCallbackInfo& info)
|
||||
func->Execute();
|
||||
};
|
||||
}
|
||||
auto onDateChange = paramObject->GetProperty("onDateChange");
|
||||
if (!onDateChange->IsUndefined() && onDateChange->IsFunction()) {
|
||||
auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(onDateChange));
|
||||
dateChangeEvent = [execCtx = info.GetExecutionContext(), type = pickerType, func = std::move(jsFunc)](
|
||||
const std::string& info) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("DatePickerDialog.onDateChange");
|
||||
auto selectedJson = JsonUtil::ParseJsonString(info);
|
||||
if (!selectedJson || selectedJson->IsNull()) {
|
||||
return;
|
||||
}
|
||||
std::tm dateTime = { 0 };
|
||||
auto year = selectedJson->GetValue("year");
|
||||
if (year && year->IsNumber()) {
|
||||
dateTime.tm_year = year->GetInt() - 1900; // local date start from 1900
|
||||
}
|
||||
auto month = selectedJson->GetValue("month");
|
||||
if (month && month->IsNumber()) {
|
||||
dateTime.tm_mon = month->GetInt();
|
||||
}
|
||||
auto day = selectedJson->GetValue("day");
|
||||
if (day && day->IsNumber()) {
|
||||
dateTime.tm_mday = day->GetInt();
|
||||
}
|
||||
auto hour = selectedJson->GetValue("hour");
|
||||
if (hour && hour->IsNumber()) {
|
||||
dateTime.tm_hour = hour->GetInt();
|
||||
}
|
||||
auto minute = selectedJson->GetValue("minute");
|
||||
if (minute && minute->IsNumber()) {
|
||||
dateTime.tm_min = minute->GetInt();
|
||||
}
|
||||
|
||||
auto milliseconds = Date::GetMilliSecondsByDateTime(dateTime);
|
||||
auto dateObj = JSDate::New(milliseconds);
|
||||
func->ExecuteJS(1, &dateObj);
|
||||
};
|
||||
}
|
||||
auto onDateAccept = paramObject->GetProperty("onDateAccept");
|
||||
if (!onDateAccept->IsUndefined() && onDateAccept->IsFunction()) {
|
||||
auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(onDateAccept));
|
||||
dateAcceptEvent = [execCtx = info.GetExecutionContext(), type = pickerType, func = std::move(jsFunc)](
|
||||
const std::string& info) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("DatePickerDialog.onDateAccept");
|
||||
auto selectedJson = JsonUtil::ParseJsonString(info);
|
||||
if (!selectedJson || selectedJson->IsNull()) {
|
||||
return;
|
||||
}
|
||||
std::tm dateTime = { 0 };
|
||||
auto year = selectedJson->GetValue("year");
|
||||
if (year && year->IsNumber()) {
|
||||
dateTime.tm_year = year->GetInt() - 1900; // local date start from 1900
|
||||
}
|
||||
auto month = selectedJson->GetValue("month");
|
||||
if (month && month->IsNumber()) {
|
||||
dateTime.tm_mon = month->GetInt();
|
||||
}
|
||||
auto day = selectedJson->GetValue("day");
|
||||
if (day && day->IsNumber()) {
|
||||
dateTime.tm_mday = day->GetInt();
|
||||
}
|
||||
auto hour = selectedJson->GetValue("hour");
|
||||
if (hour && hour->IsNumber()) {
|
||||
dateTime.tm_hour = hour->GetInt();
|
||||
}
|
||||
auto minute = selectedJson->GetValue("minute");
|
||||
if (minute && minute->IsNumber()) {
|
||||
dateTime.tm_min = minute->GetInt();
|
||||
}
|
||||
|
||||
auto milliseconds = Date::GetMilliSecondsByDateTime(dateTime);
|
||||
auto dateObj = JSDate::New(milliseconds);
|
||||
func->ExecuteJS(1, &dateObj);
|
||||
};
|
||||
}
|
||||
NG::DatePickerSettingData settingData;
|
||||
PickerDialogInfo pickerDialog;
|
||||
auto startDate = paramObject->GetProperty("start");
|
||||
@ -661,7 +810,8 @@ void JSDatePickerDialog::Show(const JSCallbackInfo& info)
|
||||
pickerDialog.pickerTime = ParseTime(selectedDate);
|
||||
JSDatePicker::ParseTextProperties(paramObject, settingData.properties);
|
||||
DatePickerDialogModel::GetInstance()->SetDatePickerDialogShow(
|
||||
pickerDialog, settingData, std::move(cancelEvent), std::move(acceptEvent), std::move(changeEvent), pickerType);
|
||||
pickerDialog, settingData, std::move(cancelEvent), std::move(acceptEvent), std::move(changeEvent),
|
||||
std::move(dateAcceptEvent), std::move(dateChangeEvent), pickerType);
|
||||
}
|
||||
|
||||
void JSDatePickerDialog::DatePickerDialogShow(const JSRef<JSObject>& paramObj,
|
||||
@ -1070,11 +1220,14 @@ void JSTimePickerDialog::Show(const JSCallbackInfo& info)
|
||||
NG::TimePickerSettingData settingData;
|
||||
PickerDialogInfo pickerDialog;
|
||||
settingData.isUseMilitaryTime = useMilitaryTime->ToBoolean();
|
||||
pickerDialog.pickerTime = ParseTime(selectedTime);
|
||||
pickerDialog.isUseMilitaryTime = useMilitaryTime->ToBoolean();
|
||||
if (selectedTime->IsObject()) {
|
||||
settingData.dialogTitleDate = ParseDate(selectedTime);
|
||||
pickerDialog.isSelectedTime = true;
|
||||
PickerDate dialogTitleDate = ParseDate(selectedTime);
|
||||
if (dialogTitleDate.GetYear() != 0) {
|
||||
settingData.dialogTitleDate = dialogTitleDate;
|
||||
pickerDialog.isSelectedTime = true;
|
||||
pickerDialog.pickerTime = ParseTime(selectedTime);
|
||||
}
|
||||
}
|
||||
JSDatePicker::ParseTextProperties(paramObject, settingData.properties);
|
||||
TimePickerDialogModel::GetInstance()->SetTimePickerDialogShow(
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
static void JSBind(BindingTarget globalObj);
|
||||
static void SetLunar(bool isLunar);
|
||||
static void OnChange(const JSCallbackInfo& info);
|
||||
static void OnDateChange(const JSCallbackInfo& info);
|
||||
static void PickerBackgroundColor(const JSCallbackInfo& info);
|
||||
static void SetDisappearTextStyle(const JSCallbackInfo& info);
|
||||
static void SetTextStyle(const JSCallbackInfo& info);
|
||||
|
@ -270,7 +270,7 @@ void JSGrid::SetScrollBar(int32_t displayMode)
|
||||
|
||||
void JSGrid::SetScrollBarColor(const std::string& color)
|
||||
{
|
||||
if (!color.empty()) {
|
||||
if (!color.empty() && color != "undefined") {
|
||||
GridModel::GetInstance()->SetScrollBarColor(color);
|
||||
return;
|
||||
}
|
||||
|
@ -194,8 +194,10 @@ void JSList::SetLanes(const JSCallbackInfo& info)
|
||||
|
||||
if (info.Length() >= 2 && !(info[1]->IsNull())) { /* 2: parameter count */
|
||||
CalcDimension laneGutter;
|
||||
if (!JSViewAbstract::ParseJsDimensionVp(info[1], laneGutter)) {
|
||||
ListModel::GetInstance()->SetLaneGutter(0.0_vp);
|
||||
if (JSViewAbstract::ParseJsDimensionVp(info[1], laneGutter)) {
|
||||
if (laneGutter.IsNegative()) {
|
||||
laneGutter.Reset();
|
||||
}
|
||||
}
|
||||
ListModel::GetInstance()->SetLaneGutter(laneGutter);
|
||||
}
|
||||
|
@ -184,40 +184,52 @@ void JSListItem::JsParseDeleteArea(const JSCallbackInfo& args, const JSRef<JSVal
|
||||
if (defaultDeleteAnimation->IsBoolean()) {
|
||||
useDefaultDeleteAnimation = defaultDeleteAnimation->ToBoolean();
|
||||
}
|
||||
auto onDelete = deleteAreaObj->GetProperty("onDelete");
|
||||
std::function<void()> onDeleteCallback;
|
||||
if (onDelete->IsFunction()) {
|
||||
onDeleteCallback = [execCtx = args.GetExecutionContext(), func = JSRef<JSFunc>::Cast(onDelete)]() {
|
||||
auto onAction = deleteAreaObj->GetProperty("onAction");
|
||||
if (!onAction->IsFunction()) {
|
||||
onAction = deleteAreaObj->GetProperty("onDelete");
|
||||
}
|
||||
std::function<void()> onActionCallback;
|
||||
if (onAction->IsFunction()) {
|
||||
onActionCallback = [execCtx = args.GetExecutionContext(), func = JSRef<JSFunc>::Cast(onAction)]() {
|
||||
func->Call(JSRef<JSObject>());
|
||||
return;
|
||||
};
|
||||
}
|
||||
auto onEnterDeleteArea = deleteAreaObj->GetProperty("onEnterDeleteArea");
|
||||
std::function<void()> onEnterDeleteAreaCallback;
|
||||
if (onEnterDeleteArea->IsFunction()) {
|
||||
onEnterDeleteAreaCallback = [execCtx = args.GetExecutionContext(),
|
||||
func = JSRef<JSFunc>::Cast(onEnterDeleteArea)]() {
|
||||
auto onEnterActionArea = deleteAreaObj->GetProperty("onEnterActionArea");
|
||||
if (!onEnterActionArea->IsFunction()) {
|
||||
onEnterActionArea = deleteAreaObj->GetProperty("onEnterDeleteArea");
|
||||
}
|
||||
std::function<void()> onEnterActionAreaCallback;
|
||||
if (onEnterActionArea->IsFunction()) {
|
||||
onEnterActionAreaCallback = [execCtx = args.GetExecutionContext(),
|
||||
func = JSRef<JSFunc>::Cast(onEnterActionArea)]() {
|
||||
func->Call(JSRef<JSObject>());
|
||||
return;
|
||||
};
|
||||
}
|
||||
auto onExitDeleteArea = deleteAreaObj->GetProperty("onExitDeleteArea");
|
||||
std::function<void()> onExitDeleteAreaCallback;
|
||||
if (onExitDeleteArea->IsFunction()) {
|
||||
onExitDeleteAreaCallback = [execCtx = args.GetExecutionContext(),
|
||||
func = JSRef<JSFunc>::Cast(onExitDeleteArea)]() {
|
||||
auto onExitActionArea = deleteAreaObj->GetProperty("onExitActionArea");
|
||||
if (!onExitActionArea->IsFunction()) {
|
||||
onExitActionArea = deleteAreaObj->GetProperty("onExitDeleteArea");
|
||||
}
|
||||
std::function<void()> onExitActionAreaCallback;
|
||||
if (onExitActionArea->IsFunction()) {
|
||||
onExitActionAreaCallback = [execCtx = args.GetExecutionContext(),
|
||||
func = JSRef<JSFunc>::Cast(onExitActionArea)]() {
|
||||
func->Call(JSRef<JSObject>());
|
||||
return;
|
||||
};
|
||||
}
|
||||
auto deleteAreaDistance = deleteAreaObj->GetProperty("deleteAreaDistance");
|
||||
auto actionAreaDistance = deleteAreaObj->GetProperty("actionAreaDistance");
|
||||
CalcDimension length;
|
||||
if (!ParseJsDimensionVp(deleteAreaDistance, length)) {
|
||||
length = listItemTheme->GetDeleteDistance();
|
||||
if (!ParseJsDimensionVp(actionAreaDistance, length)) {
|
||||
actionAreaDistance = deleteAreaObj->GetProperty("deleteAreaDistance");
|
||||
if (!ParseJsDimensionVp(actionAreaDistance, length)) {
|
||||
length = listItemTheme->GetDeleteDistance();
|
||||
}
|
||||
}
|
||||
|
||||
ListItemModel::GetInstance()->SetDeleteArea(std::move(builderAction), useDefaultDeleteAnimation,
|
||||
std::move(onDeleteCallback), std::move(onEnterDeleteAreaCallback), std::move(onExitDeleteAreaCallback), length,
|
||||
std::move(onActionCallback), std::move(onEnterActionAreaCallback), std::move(onExitActionAreaCallback), length,
|
||||
isStartArea);
|
||||
}
|
||||
|
||||
|
@ -107,9 +107,10 @@ void JSLoadingProgress::SetForegroundColor(const JSCallbackInfo& info)
|
||||
|
||||
void JSLoadingProgress::SetEnableLoading(const JSCallbackInfo& info)
|
||||
{
|
||||
if (!info[0]->IsBoolean()) {
|
||||
return;
|
||||
bool enable = true;
|
||||
if (info[0]->IsBoolean()) {
|
||||
enable = info[0]->ToBoolean();
|
||||
}
|
||||
LoadingProgressModel::GetInstance()->SetEnableLoading(info[0]->ToBoolean());
|
||||
LoadingProgressModel::GetInstance()->SetEnableLoading(enable);
|
||||
}
|
||||
}; // namespace OHOS::Ace::Framework
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_sec_location_button.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_location_button.h"
|
||||
|
||||
#include "bridge/common/utils/utils.h"
|
||||
#include "core/common/container.h"
|
||||
@ -26,27 +26,8 @@ using OHOS::Ace::NG::LocationButtonModelNG;
|
||||
using OHOS::Ace::NG::SecurityComponentTheme;
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
static ButtonType TransformSecCompBgType(SecurityComponentBackgroundType type)
|
||||
{
|
||||
ButtonType buttonType = ButtonType::CAPSULE;
|
||||
switch (type) {
|
||||
case SecurityComponentBackgroundType::CAPSULE:
|
||||
buttonType = ButtonType::CAPSULE;
|
||||
break;
|
||||
case SecurityComponentBackgroundType::CIRCLE:
|
||||
buttonType = ButtonType::CIRCLE;
|
||||
break;
|
||||
case SecurityComponentBackgroundType::NORMAL:
|
||||
buttonType = ButtonType::NORMAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return buttonType;
|
||||
}
|
||||
|
||||
bool JSSecLocationButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
LocationButtonLocationDescription& text, LocationButtonIconStyle& icon, SecurityComponentBackgroundType& bg)
|
||||
bool JSLocationButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
LocationButtonLocationDescription& text, LocationButtonIconStyle& icon, int32_t& bg)
|
||||
{
|
||||
if (!info[0]->IsObject()) {
|
||||
return false;
|
||||
@ -80,41 +61,36 @@ bool JSSecLocationButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
return false;
|
||||
}
|
||||
|
||||
value = paramObject->GetProperty("background");
|
||||
value = paramObject->GetProperty("buttonType");
|
||||
if (value->IsNumber()) {
|
||||
bg = static_cast<SecurityComponentBackgroundType>(value->ToNumber<int32_t>());
|
||||
if ((bg < SecurityComponentBackgroundType::CAPSULE) ||
|
||||
(bg > SecurityComponentBackgroundType::NORMAL)) {
|
||||
bg = value->ToNumber<int32_t>();
|
||||
if ((bg < static_cast<int32_t>(ButtonType::NORMAL)) ||
|
||||
(bg > static_cast<int32_t>(ButtonType::CIRCLE))) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
bg = SecurityComponentBackgroundType::BACKGROUND_NULL;
|
||||
bg = BUTTON_TYPE_NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void JSSecLocationButton::Create(const JSCallbackInfo& info)
|
||||
void JSLocationButton::Create(const JSCallbackInfo& info)
|
||||
{
|
||||
LocationButtonLocationDescription textDesc;
|
||||
LocationButtonIconStyle iconType;
|
||||
SecurityComponentBackgroundType backgroundType;
|
||||
int32_t backgroundType = 0;
|
||||
if (!ParseComponentStyle(info, textDesc, iconType, backgroundType)) {
|
||||
LocationButtonModelNG::GetInstance()->Create(
|
||||
static_cast<int32_t>(LocationButtonLocationDescription::CURRENT_LOCATION),
|
||||
static_cast<int32_t>(LocationButtonIconStyle::ICON_FULL_FILLED),
|
||||
static_cast<int32_t>(LocationButtonIconStyle::ICON_LINE),
|
||||
static_cast<int32_t>(ButtonType::CAPSULE));
|
||||
} else {
|
||||
if (backgroundType == SecurityComponentBackgroundType::BACKGROUND_NULL) {
|
||||
LocationButtonModelNG::GetInstance()->Create(static_cast<int32_t>(textDesc),
|
||||
static_cast<int32_t>(iconType), static_cast<int32_t>(backgroundType));
|
||||
} else {
|
||||
LocationButtonModelNG::GetInstance()->Create(static_cast<int32_t>(textDesc),
|
||||
static_cast<int32_t>(iconType), static_cast<int32_t>(TransformSecCompBgType(backgroundType)));
|
||||
}
|
||||
LocationButtonModelNG::GetInstance()->Create(static_cast<int32_t>(textDesc),
|
||||
static_cast<int32_t>(iconType), backgroundType);
|
||||
}
|
||||
}
|
||||
|
||||
void JsSecLocationButtonClickFunction::Execute(GestureEvent& info)
|
||||
void JsLocationButtonClickFunction::Execute(GestureEvent& info)
|
||||
{
|
||||
JSRef<JSObject> clickEventParam = JSRef<JSObject>::New();
|
||||
Offset globalOffset = info.GetGlobalLocation();
|
||||
@ -145,16 +121,16 @@ void JsSecLocationButtonClickFunction::Execute(GestureEvent& info)
|
||||
}
|
||||
#endif
|
||||
JSRef<JSVal> errorParam = JSRef<JSVal>::Make(ToJSValue(res));
|
||||
JSRef<JSVal> params[] = { errorParam, clickEventParam };
|
||||
JSRef<JSVal> params[] = { clickEventParam, errorParam };
|
||||
JsFunction::ExecuteJS(2, params);
|
||||
}
|
||||
|
||||
void JSSecLocationButton::JsOnClick(const JSCallbackInfo& info)
|
||||
void JSLocationButton::JsOnClick(const JSCallbackInfo& info)
|
||||
{
|
||||
if (!info[0]->IsFunction()) {
|
||||
return;
|
||||
}
|
||||
auto jsOnClickFunc = AceType::MakeRefPtr<JsSecLocationButtonClickFunction>(JSRef<JSFunc>::Cast(info[0]));
|
||||
auto jsOnClickFunc = AceType::MakeRefPtr<JsLocationButtonClickFunction>(JSRef<JSFunc>::Cast(info[0]));
|
||||
auto onTap = [execCtx = info.GetExecutionContext(), func = jsOnClickFunc](GestureEvent& info) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("onClick");
|
||||
@ -164,36 +140,35 @@ void JSSecLocationButton::JsOnClick(const JSCallbackInfo& info)
|
||||
NG::ViewAbstract::SetOnClick(std::move(onTap));
|
||||
}
|
||||
|
||||
void JSSecLocationButton::JSBind(BindingTarget globalObj)
|
||||
void JSLocationButton::JSBind(BindingTarget globalObj)
|
||||
{
|
||||
JSClass<JSSecLocationButton>::Declare("SecLocationButton");
|
||||
JSClass<JSLocationButton>::Declare("LocationButton");
|
||||
MethodOptions opt = MethodOptions::NONE;
|
||||
JSClass<JSSecLocationButton>::StaticMethod("create", &JSSecLocationButton::Create, opt);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("iconSize", &JSSecButtonBase::SetIconSize);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("layoutDirection", &JSSecButtonBase::SetLayoutDirection);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("layoutOrder", &JSSecButtonBase::SetlayoutOrder);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("fontSize", &JSSecButtonBase::SetFontSize);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("fontStyle", &JSSecButtonBase::SetFontStyle);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("iconColor", &JSSecButtonBase::SetIconColor);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("fontWeight", &JSSecButtonBase::SetFontWeight);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("fontFamily", &JSSecButtonBase::SetFontFamily);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("fontColor", &JSSecButtonBase::SetFontColor);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("backgroundColor", &JSSecButtonBase::SetBackgroundColor);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("borderStyle", &JSSecButtonBase::SetBackgroundBorderStyle);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("borderWidth", &JSSecButtonBase::SetBackgroundBorderWidth);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("borderColor", &JSSecButtonBase::SetBackgroundBorderColor);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("borderRadius", &JSSecButtonBase::SetBackgroundBorderRadius);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("backgroundPadding", &JSSecButtonBase::SetBackgroundPadding);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("textIconPadding", &JSSecButtonBase::SetTextIconSpace);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("onClick", &JSSecLocationButton::JsOnClick);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("key", &JSViewAbstract::JsKey);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("position", &JSViewAbstract::JsPosition);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("markAnchor", &JSViewAbstract::JsMarkAnchor);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("offset", &JSViewAbstract::JsOffset);
|
||||
JSClass<JSSecLocationButton>::StaticMethod("pop", &JSViewAbstract::Pop, opt);
|
||||
JSClass<JSLocationButton>::StaticMethod("create", &JSLocationButton::Create, opt);
|
||||
JSClass<JSLocationButton>::StaticMethod("iconSize", &JSSecButtonBase::SetIconSize);
|
||||
JSClass<JSLocationButton>::StaticMethod("layoutDirection", &JSSecButtonBase::SetLayoutDirection);
|
||||
JSClass<JSLocationButton>::StaticMethod("fontSize", &JSSecButtonBase::SetFontSize);
|
||||
JSClass<JSLocationButton>::StaticMethod("fontStyle", &JSSecButtonBase::SetFontStyle);
|
||||
JSClass<JSLocationButton>::StaticMethod("iconColor", &JSSecButtonBase::SetIconColor);
|
||||
JSClass<JSLocationButton>::StaticMethod("fontWeight", &JSSecButtonBase::SetFontWeight);
|
||||
JSClass<JSLocationButton>::StaticMethod("fontFamily", &JSSecButtonBase::SetFontFamily);
|
||||
JSClass<JSLocationButton>::StaticMethod("fontColor", &JSSecButtonBase::SetFontColor);
|
||||
JSClass<JSLocationButton>::StaticMethod("backgroundColor", &JSSecButtonBase::SetBackgroundColor);
|
||||
JSClass<JSLocationButton>::StaticMethod("borderStyle", &JSSecButtonBase::SetBackgroundBorderStyle);
|
||||
JSClass<JSLocationButton>::StaticMethod("borderWidth", &JSSecButtonBase::SetBackgroundBorderWidth);
|
||||
JSClass<JSLocationButton>::StaticMethod("borderColor", &JSSecButtonBase::SetBackgroundBorderColor);
|
||||
JSClass<JSLocationButton>::StaticMethod("borderRadius", &JSSecButtonBase::SetBackgroundBorderRadius);
|
||||
JSClass<JSLocationButton>::StaticMethod("padding", &JSSecButtonBase::SetBackgroundPadding);
|
||||
JSClass<JSLocationButton>::StaticMethod("textIconSpace", &JSSecButtonBase::SetTextIconSpace);
|
||||
JSClass<JSLocationButton>::StaticMethod("onClick", &JSLocationButton::JsOnClick);
|
||||
JSClass<JSLocationButton>::StaticMethod("key", &JSViewAbstract::JsKey);
|
||||
JSClass<JSLocationButton>::StaticMethod("position", &JSViewAbstract::JsPosition);
|
||||
JSClass<JSLocationButton>::StaticMethod("markAnchor", &JSViewAbstract::JsMarkAnchor);
|
||||
JSClass<JSLocationButton>::StaticMethod("offset", &JSViewAbstract::JsOffset);
|
||||
JSClass<JSLocationButton>::StaticMethod("pop", &JSViewAbstract::Pop, opt);
|
||||
#if defined(PREVIEW)
|
||||
JSClass<JSSecLocationButton>::StaticMethod("debugLine", &JSViewAbstract::JsDebugLine);
|
||||
JSClass<JSLocationButton>::StaticMethod("debugLine", &JSViewAbstract::JsDebugLine);
|
||||
#endif
|
||||
JSClass<JSSecLocationButton>::Bind<>(globalObj);
|
||||
JSClass<JSLocationButton>::Bind<>(globalObj);
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_LOCATION_BUTTON_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_LOCATION_BUTTON_H
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_LOCATION_BUTTON_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_LOCATION_BUTTON_H
|
||||
|
||||
#include "bridge/declarative_frontend/engine/bindings.h"
|
||||
#include "bridge/declarative_frontend/engine/functions/js_function.h"
|
||||
@ -26,13 +26,13 @@
|
||||
#include "core/gestures/click_recognizer.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
class JsSecLocationButtonClickFunction : public JsFunction {
|
||||
DECLARE_ACE_TYPE(JsSecLocationButtonClickFunction, JsFunction)
|
||||
class JsLocationButtonClickFunction : public JsFunction {
|
||||
DECLARE_ACE_TYPE(JsLocationButtonClickFunction, JsFunction)
|
||||
public:
|
||||
explicit JsSecLocationButtonClickFunction(const JSRef<JSFunc>& jsFunction) :
|
||||
explicit JsLocationButtonClickFunction(const JSRef<JSFunc>& jsFunction) :
|
||||
JsFunction(JSRef<JSObject>(), jsFunction) {}
|
||||
|
||||
~JsSecLocationButtonClickFunction() override {};
|
||||
~JsLocationButtonClickFunction() override {};
|
||||
void Execute() override
|
||||
{
|
||||
JsFunction::ExecuteJS();
|
||||
@ -41,13 +41,13 @@ public:
|
||||
void Execute(GestureEvent& info);
|
||||
};
|
||||
|
||||
class JSSecLocationButton : public JSViewAbstract, public JSInteractableView {
|
||||
class JSLocationButton : public JSViewAbstract, public JSInteractableView {
|
||||
public:
|
||||
static void JSBind(BindingTarget globalObj);
|
||||
static bool ParseComponentStyle(const JSCallbackInfo& info, LocationButtonLocationDescription& text,
|
||||
LocationButtonIconStyle& icon, SecurityComponentBackgroundType& bg);
|
||||
LocationButtonIconStyle& icon, int32_t& bg);
|
||||
static void Create(const JSCallbackInfo& info);
|
||||
static void JsOnClick(const JSCallbackInfo& info);
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_LOCATION_BUTTON_H
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_LOCATION_BUTTON_H
|
@ -27,9 +27,9 @@
|
||||
#include "bridge/declarative_frontend/jsview/js_view_abstract.h"
|
||||
#include "bridge/declarative_frontend/jsview/models/navigation_model_impl.h"
|
||||
#include "core/components_ng/base/view_stack_model.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_declaration.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_model_data.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_model_ng.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_declaration.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
std::unique_ptr<NavigationModel> NavigationModel::instance_ = nullptr;
|
||||
@ -60,7 +60,9 @@ namespace {
|
||||
constexpr int32_t TITLE_MODE_RANGE = 2;
|
||||
constexpr int32_t NAVIGATION_MODE_RANGE = 2;
|
||||
constexpr int32_t NAV_BAR_POSITION_RANGE = 1;
|
||||
constexpr int32_t DEFAULT_NAV_BAR_WIDTH = 240;
|
||||
constexpr int32_t DEFAULT_NAV_BAR_WIDTH = 200;
|
||||
constexpr Dimension DEFAULT_MIN_NAV_BAR_WIDTH = 240.0_vp;
|
||||
constexpr Dimension DEFAULT_MAX_NAV_BAR_WIDTH = 280.0_vp;
|
||||
constexpr Dimension DEFAULT_MIN_CONTENT_WIDTH = 360.0_vp;
|
||||
|
||||
JSRef<JSVal> TitleModeChangeEventToJSValue(const NavigationTitleModeChangeEvent& eventInfo)
|
||||
@ -210,7 +212,8 @@ bool JSNavigation::ParseCommonTitle(const JSRef<JSVal>& jsValue)
|
||||
bool sub = subtitle->IsString();
|
||||
bool main = title->IsString();
|
||||
if (subtitle->IsString() || title->IsString()) {
|
||||
NavigationModel::GetInstance()->ParseCommonTitle(sub, main, subtitle->ToString(), title->ToString());
|
||||
NavigationModel::GetInstance()->ParseCommonTitle(
|
||||
sub, main, subtitle->ToString(), title->ToString());
|
||||
}
|
||||
return isCommonTitle;
|
||||
}
|
||||
@ -494,7 +497,7 @@ void JSNavigation::SetOnTitleModeChanged(const JSCallbackInfo& info)
|
||||
auto onTitleModeChangeCallback =
|
||||
AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
|
||||
auto onTitleModeChange = [execCtx = info.GetExecutionContext(), func = std::move(onTitleModeChangeCallback)](
|
||||
NG::NavigationTitleMode mode) {
|
||||
NG::NavigationTitleMode mode) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("OnTitleModeChange");
|
||||
JSRef<JSVal> param = JSRef<JSVal>::Make(ToJSValue(mode));
|
||||
@ -503,7 +506,7 @@ void JSNavigation::SetOnTitleModeChanged(const JSCallbackInfo& info)
|
||||
auto changeHandler = AceType::MakeRefPtr<JsEventFunction<NavigationTitleModeChangeEvent, 1>>(
|
||||
JSRef<JSFunc>::Cast(info[0]), TitleModeChangeEventToJSValue);
|
||||
auto eventInfo = [executionContext = info.GetExecutionContext(), func = std::move(changeHandler)](
|
||||
const BaseEventInfo* baseInfo) {
|
||||
const BaseEventInfo* baseInfo) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(executionContext);
|
||||
auto eventInfo = TypeInfoHelper::DynamicCast<NavigationTitleModeChangeEvent>(baseInfo);
|
||||
if (!eventInfo) {
|
||||
@ -577,6 +580,7 @@ void JSNavigation::SetMinContentWidth(const JSCallbackInfo& info)
|
||||
|
||||
void JSNavigation::SetNavBarWidthRange(const JSCallbackInfo& info)
|
||||
{
|
||||
|
||||
if (info.Length() < 1) {
|
||||
LOGE("The arg is wrong, it is supposed to have at least 1 argument");
|
||||
return;
|
||||
@ -587,19 +591,26 @@ void JSNavigation::SetNavBarWidthRange(const JSCallbackInfo& info)
|
||||
JSRef<JSVal> max = rangeArray->GetValueAt(1);
|
||||
|
||||
CalcDimension minNavBarWidth;
|
||||
if (!ParseJsDimensionVp(min, minNavBarWidth)) {
|
||||
minNavBarWidth = DEFAULT_MIN_NAV_BAR_WIDTH;
|
||||
}
|
||||
|
||||
CalcDimension maxNavBarWidth;
|
||||
ParseJsDimensionVp(min, minNavBarWidth);
|
||||
ParseJsDimensionVp(max, maxNavBarWidth);
|
||||
if (!ParseJsDimensionVp(max, maxNavBarWidth)) {
|
||||
maxNavBarWidth = DEFAULT_MAX_NAV_BAR_WIDTH;
|
||||
}
|
||||
|
||||
if (LessNotEqual(minNavBarWidth.Value(), 0.0)) {
|
||||
minNavBarWidth.SetValue(0);
|
||||
minNavBarWidth = DEFAULT_MIN_NAV_BAR_WIDTH;
|
||||
}
|
||||
NavigationModel::GetInstance()->SetMinNavBarWidth(minNavBarWidth);
|
||||
|
||||
if (LessNotEqual(maxNavBarWidth.Value(), 0.0)) {
|
||||
maxNavBarWidth.SetValue(0);
|
||||
maxNavBarWidth = DEFAULT_MAX_NAV_BAR_WIDTH;
|
||||
}
|
||||
|
||||
NavigationModel::GetInstance()->SetMinNavBarWidth(minNavBarWidth);
|
||||
NavigationModel::GetInstance()->SetMaxNavBarWidth(maxNavBarWidth);
|
||||
|
||||
}
|
||||
|
||||
void JSNavigation::SetOnNavBarStateChange(const JSCallbackInfo& info)
|
||||
@ -613,7 +624,7 @@ void JSNavigation::SetOnNavBarStateChange(const JSCallbackInfo& info)
|
||||
auto onNavBarStateChangeCallback =
|
||||
AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
|
||||
auto onNavBarStateChange = [execCtx = info.GetExecutionContext(),
|
||||
func = std::move(onNavBarStateChangeCallback)](bool isVisible) {
|
||||
func = std::move(onNavBarStateChangeCallback)](bool isVisible) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("OnNavBarStateChange");
|
||||
JSRef<JSVal> param = JSRef<JSVal>::Make(ToJSValue(isVisible));
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_sec_paste_button.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_paste_button.h"
|
||||
|
||||
#include "bridge/common/utils/utils.h"
|
||||
#include "core/common/container.h"
|
||||
@ -26,7 +26,7 @@ using OHOS::Ace::NG::PasteButtonModelNG;
|
||||
using OHOS::Ace::NG::SecurityComponentTheme;
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
bool JSSecPasteButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
bool JSPasteButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
PasteButtonPasteDescription& text, PasteButtonIconStyle& icon, int32_t& bg)
|
||||
{
|
||||
if (!info[0]->IsObject()) {
|
||||
@ -73,7 +73,7 @@ bool JSSecPasteButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
return true;
|
||||
}
|
||||
|
||||
void JSSecPasteButton::Create(const JSCallbackInfo& info)
|
||||
void JSPasteButton::Create(const JSCallbackInfo& info)
|
||||
{
|
||||
PasteButtonPasteDescription textDesc;
|
||||
PasteButtonIconStyle iconType;
|
||||
@ -89,7 +89,7 @@ void JSSecPasteButton::Create(const JSCallbackInfo& info)
|
||||
}
|
||||
}
|
||||
|
||||
void JsSecPasteButtonClickFunction::Execute(GestureEvent& info)
|
||||
void JsPasteButtonClickFunction::Execute(GestureEvent& info)
|
||||
{
|
||||
JSRef<JSObject> clickEventParam = JSRef<JSObject>::New();
|
||||
Offset globalOffset = info.GetGlobalLocation();
|
||||
@ -124,12 +124,12 @@ void JsSecPasteButtonClickFunction::Execute(GestureEvent& info)
|
||||
JsFunction::ExecuteJS(2, params);
|
||||
}
|
||||
|
||||
void JSSecPasteButton::JsOnClick(const JSCallbackInfo& info)
|
||||
void JSPasteButton::JsOnClick(const JSCallbackInfo& info)
|
||||
{
|
||||
if (!info[0]->IsFunction()) {
|
||||
return;
|
||||
}
|
||||
auto jsOnClickFunc = AceType::MakeRefPtr<JsSecPasteButtonClickFunction>(JSRef<JSFunc>::Cast(info[0]));
|
||||
auto jsOnClickFunc = AceType::MakeRefPtr<JsPasteButtonClickFunction>(JSRef<JSFunc>::Cast(info[0]));
|
||||
auto onTap = [execCtx = info.GetExecutionContext(), func = jsOnClickFunc](GestureEvent& info) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("onClick");
|
||||
@ -139,36 +139,35 @@ void JSSecPasteButton::JsOnClick(const JSCallbackInfo& info)
|
||||
NG::ViewAbstract::SetOnClick(std::move(onTap));
|
||||
}
|
||||
|
||||
void JSSecPasteButton::JSBind(BindingTarget globalObj)
|
||||
void JSPasteButton::JSBind(BindingTarget globalObj)
|
||||
{
|
||||
JSClass<JSSecPasteButton>::Declare("SecPasteButton");
|
||||
JSClass<JSPasteButton>::Declare("PasteButton");
|
||||
MethodOptions opt = MethodOptions::NONE;
|
||||
JSClass<JSSecPasteButton>::StaticMethod("create", &JSSecPasteButton::Create, opt);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("iconSize", &JSSecButtonBase::SetIconSize);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("layoutDirection", &JSSecButtonBase::SetLayoutDirection);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("layoutOrder", &JSSecButtonBase::SetlayoutOrder);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("fontSize", &JSSecButtonBase::SetFontSize);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("fontStyle", &JSSecButtonBase::SetFontStyle);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("iconColor", &JSSecButtonBase::SetIconColor);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("fontWeight", &JSSecButtonBase::SetFontWeight);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("fontFamily", &JSSecButtonBase::SetFontFamily);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("fontColor", &JSSecButtonBase::SetFontColor);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("backgroundColor", &JSSecButtonBase::SetBackgroundColor);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("borderStyle", &JSSecButtonBase::SetBackgroundBorderStyle);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("borderWidth", &JSSecButtonBase::SetBackgroundBorderWidth);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("borderColor", &JSSecButtonBase::SetBackgroundBorderColor);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("borderRadius", &JSSecButtonBase::SetBackgroundBorderRadius);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("padding", &JSSecButtonBase::SetBackgroundPadding);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("textIconSpace", &JSSecButtonBase::SetTextIconSpace);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("onClick", &JSSecPasteButton::JsOnClick);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("key", &JSViewAbstract::JsKey);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("position", &JSViewAbstract::JsPosition);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("markAnchor", &JSViewAbstract::JsMarkAnchor);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("offset", &JSViewAbstract::JsOffset);
|
||||
JSClass<JSSecPasteButton>::StaticMethod("pop", &JSViewAbstract::Pop, opt);
|
||||
JSClass<JSPasteButton>::StaticMethod("create", &JSPasteButton::Create, opt);
|
||||
JSClass<JSPasteButton>::StaticMethod("iconSize", &JSSecButtonBase::SetIconSize);
|
||||
JSClass<JSPasteButton>::StaticMethod("layoutDirection", &JSSecButtonBase::SetLayoutDirection);
|
||||
JSClass<JSPasteButton>::StaticMethod("fontSize", &JSSecButtonBase::SetFontSize);
|
||||
JSClass<JSPasteButton>::StaticMethod("fontStyle", &JSSecButtonBase::SetFontStyle);
|
||||
JSClass<JSPasteButton>::StaticMethod("iconColor", &JSSecButtonBase::SetIconColor);
|
||||
JSClass<JSPasteButton>::StaticMethod("fontWeight", &JSSecButtonBase::SetFontWeight);
|
||||
JSClass<JSPasteButton>::StaticMethod("fontFamily", &JSSecButtonBase::SetFontFamily);
|
||||
JSClass<JSPasteButton>::StaticMethod("fontColor", &JSSecButtonBase::SetFontColor);
|
||||
JSClass<JSPasteButton>::StaticMethod("backgroundColor", &JSSecButtonBase::SetBackgroundColor);
|
||||
JSClass<JSPasteButton>::StaticMethod("borderStyle", &JSSecButtonBase::SetBackgroundBorderStyle);
|
||||
JSClass<JSPasteButton>::StaticMethod("borderWidth", &JSSecButtonBase::SetBackgroundBorderWidth);
|
||||
JSClass<JSPasteButton>::StaticMethod("borderColor", &JSSecButtonBase::SetBackgroundBorderColor);
|
||||
JSClass<JSPasteButton>::StaticMethod("borderRadius", &JSSecButtonBase::SetBackgroundBorderRadius);
|
||||
JSClass<JSPasteButton>::StaticMethod("padding", &JSSecButtonBase::SetBackgroundPadding);
|
||||
JSClass<JSPasteButton>::StaticMethod("textIconSpace", &JSSecButtonBase::SetTextIconSpace);
|
||||
JSClass<JSPasteButton>::StaticMethod("onClick", &JSPasteButton::JsOnClick);
|
||||
JSClass<JSPasteButton>::StaticMethod("key", &JSViewAbstract::JsKey);
|
||||
JSClass<JSPasteButton>::StaticMethod("position", &JSViewAbstract::JsPosition);
|
||||
JSClass<JSPasteButton>::StaticMethod("markAnchor", &JSViewAbstract::JsMarkAnchor);
|
||||
JSClass<JSPasteButton>::StaticMethod("offset", &JSViewAbstract::JsOffset);
|
||||
JSClass<JSPasteButton>::StaticMethod("pop", &JSViewAbstract::Pop, opt);
|
||||
#if defined(PREVIEW)
|
||||
JSClass<JSSecPasteButton>::StaticMethod("debugLine", &JSViewAbstract::JsDebugLine);
|
||||
JSClass<JSPasteButton>::StaticMethod("debugLine", &JSViewAbstract::JsDebugLine);
|
||||
#endif
|
||||
JSClass<JSSecPasteButton>::Bind<>(globalObj);
|
||||
JSClass<JSPasteButton>::Bind<>(globalObj);
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_PASTE_BUTTON_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_PASTE_BUTTON_H
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_PASTE_BUTTON_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_PASTE_BUTTON_H
|
||||
|
||||
#include "bridge/declarative_frontend/engine/bindings.h"
|
||||
#include "bridge/declarative_frontend/engine/functions/js_function.h"
|
||||
@ -26,13 +26,13 @@
|
||||
#include "core/gestures/click_recognizer.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
class JsSecPasteButtonClickFunction : public JsFunction {
|
||||
DECLARE_ACE_TYPE(JsSecPasteButtonClickFunction, JsFunction)
|
||||
class JsPasteButtonClickFunction : public JsFunction {
|
||||
DECLARE_ACE_TYPE(JsPasteButtonClickFunction, JsFunction)
|
||||
public:
|
||||
explicit JsSecPasteButtonClickFunction(const JSRef<JSFunc>& jsFunction) :
|
||||
explicit JsPasteButtonClickFunction(const JSRef<JSFunc>& jsFunction) :
|
||||
JsFunction(JSRef<JSObject>(), jsFunction) {}
|
||||
|
||||
~JsSecPasteButtonClickFunction() override {};
|
||||
~JsPasteButtonClickFunction() override {};
|
||||
void Execute() override
|
||||
{
|
||||
JsFunction::ExecuteJS();
|
||||
@ -41,7 +41,7 @@ public:
|
||||
void Execute(GestureEvent& info);
|
||||
};
|
||||
|
||||
class JSSecPasteButton : public JSViewAbstract, public JSInteractableView {
|
||||
class JSPasteButton : public JSViewAbstract, public JSInteractableView {
|
||||
public:
|
||||
static void JSBind(BindingTarget globalObj);
|
||||
static bool ParseComponentStyle(const JSCallbackInfo& info, PasteButtonPasteDescription& text,
|
||||
@ -50,4 +50,4 @@ public:
|
||||
static void JsOnClick(const JSCallbackInfo& info);
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_PASTE_BUTTON_H
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_PASTE_BUTTON_H
|
@ -409,17 +409,13 @@ ImageSpanAttribute JSRichEditorController::ParseJsImageSpanAttribute(JSRef<JSObj
|
||||
JSRef<JSArray> size = JSRef<JSArray>::Cast(sizeObj);
|
||||
JSRef<JSVal> width = size->GetValueAt(0);
|
||||
CalcDimension imageSpanWidth;
|
||||
if (!width->IsNull() && (JSContainerBase::ParseJsDimensionVp(width, imageSpanWidth) ||
|
||||
JSContainerBase::ParseJsDimensionFp(width, imageSpanWidth) ||
|
||||
JSContainerBase::ParseJsDimensionPx(width, imageSpanWidth))) {
|
||||
if (!width->IsNull() && JSContainerBase::ParseJsDimensionVp(width, imageSpanWidth)) {
|
||||
imageSize.width = imageSpanWidth;
|
||||
updateSpanStyle_.updateImageWidth = imageSpanWidth;
|
||||
}
|
||||
JSRef<JSVal> height = size->GetValueAt(1);
|
||||
CalcDimension imageSpanHeight;
|
||||
if (!height->IsNull() && (JSContainerBase::ParseJsDimensionVp(height, imageSpanHeight) ||
|
||||
JSContainerBase::ParseJsDimensionFp(height, imageSpanHeight) ||
|
||||
JSContainerBase::ParseJsDimensionPx(height, imageSpanHeight))) {
|
||||
if (!height->IsNull() && JSContainerBase::ParseJsDimensionVp(height, imageSpanHeight)) {
|
||||
imageSize.height = imageSpanHeight;
|
||||
updateSpanStyle_.updateImageHeight = imageSpanHeight;
|
||||
}
|
||||
@ -511,13 +507,19 @@ void JSRichEditorController::AddImageSpan(const JSCallbackInfo& args)
|
||||
return;
|
||||
}
|
||||
if (options.image.has_value()) {
|
||||
SrcType srcType = ImageSourceInfo::ResolveURIType(options.image.value());
|
||||
std::string assetSrc = options.image.value();
|
||||
SrcType srcType = ImageSourceInfo::ResolveURIType(assetSrc);
|
||||
if (assetSrc[0] == '/') {
|
||||
assetSrc = assetSrc.substr(1); // get the asset src without '/'.
|
||||
} else if (assetSrc[0] == '.' && assetSrc.size() > 2 && assetSrc[1] == '/') {
|
||||
assetSrc = assetSrc.substr(2); // get the asset src without './'.
|
||||
}
|
||||
if (srcType == SrcType::ASSET) {
|
||||
auto pipelineContext = PipelineBase::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipelineContext);
|
||||
auto assetManager = pipelineContext->GetAssetManager();
|
||||
CHECK_NULL_VOID(assetManager);
|
||||
auto assetData = assetManager->GetAsset(options.image.value());
|
||||
auto assetData = assetManager->GetAsset(assetSrc);
|
||||
if (!assetData) {
|
||||
args.SetReturnValue(JSRef<JSVal>::Make(ToJSValue(-1)));
|
||||
return;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_sec_save_button.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_save_button.h"
|
||||
|
||||
#include "bridge/common/utils/utils.h"
|
||||
#include "core/common/container.h"
|
||||
@ -26,7 +26,7 @@ using OHOS::Ace::NG::SaveButtonModelNG;
|
||||
using OHOS::Ace::NG::SecurityComponentTheme;
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
bool JSSecSaveButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
bool JSSaveButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
SaveButtonSaveDescription& text, SaveButtonIconStyle& icon, int32_t& bg)
|
||||
{
|
||||
if (!info[0]->IsObject()) {
|
||||
@ -74,7 +74,7 @@ bool JSSecSaveButton::ParseComponentStyle(const JSCallbackInfo& info,
|
||||
return true;
|
||||
}
|
||||
|
||||
void JSSecSaveButton::Create(const JSCallbackInfo& info)
|
||||
void JSSaveButton::Create(const JSCallbackInfo& info)
|
||||
{
|
||||
SaveButtonSaveDescription textDesc;
|
||||
SaveButtonIconStyle iconType;
|
||||
@ -90,7 +90,7 @@ void JSSecSaveButton::Create(const JSCallbackInfo& info)
|
||||
}
|
||||
}
|
||||
|
||||
void JsSecSaveButtonClickFunction::Execute(GestureEvent& info)
|
||||
void JsSaveButtonClickFunction::Execute(GestureEvent& info)
|
||||
{
|
||||
JSRef<JSObject> clickEventParam = JSRef<JSObject>::New();
|
||||
Offset globalOffset = info.GetGlobalLocation();
|
||||
@ -125,12 +125,12 @@ void JsSecSaveButtonClickFunction::Execute(GestureEvent& info)
|
||||
JsFunction::ExecuteJS(2, params);
|
||||
}
|
||||
|
||||
void JSSecSaveButton::JsOnClick(const JSCallbackInfo& info)
|
||||
void JSSaveButton::JsOnClick(const JSCallbackInfo& info)
|
||||
{
|
||||
if (!info[0]->IsFunction()) {
|
||||
return;
|
||||
}
|
||||
auto jsOnClickFunc = AceType::MakeRefPtr<JsSecSaveButtonClickFunction>(JSRef<JSFunc>::Cast(info[0]));
|
||||
auto jsOnClickFunc = AceType::MakeRefPtr<JsSaveButtonClickFunction>(JSRef<JSFunc>::Cast(info[0]));
|
||||
auto onTap = [execCtx = info.GetExecutionContext(), func = jsOnClickFunc](GestureEvent& info) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
ACE_SCORING_EVENT("onClick");
|
||||
@ -140,36 +140,35 @@ void JSSecSaveButton::JsOnClick(const JSCallbackInfo& info)
|
||||
NG::ViewAbstract::SetOnClick(std::move(onTap));
|
||||
}
|
||||
|
||||
void JSSecSaveButton::JSBind(BindingTarget globalObj)
|
||||
void JSSaveButton::JSBind(BindingTarget globalObj)
|
||||
{
|
||||
JSClass<JSSecSaveButton>::Declare("SecSaveButton");
|
||||
JSClass<JSSaveButton>::Declare("SaveButton");
|
||||
MethodOptions opt = MethodOptions::NONE;
|
||||
JSClass<JSSecSaveButton>::StaticMethod("create", &JSSecSaveButton::Create, opt);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("iconSize", &JSSecButtonBase::SetIconSize);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("layoutDirection", &JSSecButtonBase::SetLayoutDirection);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("layoutOrder", &JSSecButtonBase::SetlayoutOrder);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("fontSize", &JSSecButtonBase::SetFontSize);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("fontStyle", &JSSecButtonBase::SetFontStyle);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("iconColor", &JSSecButtonBase::SetIconColor);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("fontWeight", &JSSecButtonBase::SetFontWeight);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("fontFamily", &JSSecButtonBase::SetFontFamily);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("fontColor", &JSSecButtonBase::SetFontColor);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("backgroundColor", &JSSecButtonBase::SetBackgroundColor);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("borderStyle", &JSSecButtonBase::SetBackgroundBorderStyle);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("borderWidth", &JSSecButtonBase::SetBackgroundBorderWidth);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("borderColor", &JSSecButtonBase::SetBackgroundBorderColor);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("borderRadius", &JSSecButtonBase::SetBackgroundBorderRadius);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("padding", &JSSecButtonBase::SetBackgroundPadding);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("textIconSpace", &JSSecButtonBase::SetTextIconSpace);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("onClick", &JSSecSaveButton::JsOnClick);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("key", &JSViewAbstract::JsKey);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("position", &JSViewAbstract::JsPosition);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("markAnchor", &JSViewAbstract::JsMarkAnchor);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("offset", &JSViewAbstract::JsOffset);
|
||||
JSClass<JSSecSaveButton>::StaticMethod("pop", &JSViewAbstract::Pop, opt);
|
||||
JSClass<JSSaveButton>::StaticMethod("create", &JSSaveButton::Create, opt);
|
||||
JSClass<JSSaveButton>::StaticMethod("iconSize", &JSSecButtonBase::SetIconSize);
|
||||
JSClass<JSSaveButton>::StaticMethod("layoutDirection", &JSSecButtonBase::SetLayoutDirection);
|
||||
JSClass<JSSaveButton>::StaticMethod("fontSize", &JSSecButtonBase::SetFontSize);
|
||||
JSClass<JSSaveButton>::StaticMethod("fontStyle", &JSSecButtonBase::SetFontStyle);
|
||||
JSClass<JSSaveButton>::StaticMethod("iconColor", &JSSecButtonBase::SetIconColor);
|
||||
JSClass<JSSaveButton>::StaticMethod("fontWeight", &JSSecButtonBase::SetFontWeight);
|
||||
JSClass<JSSaveButton>::StaticMethod("fontFamily", &JSSecButtonBase::SetFontFamily);
|
||||
JSClass<JSSaveButton>::StaticMethod("fontColor", &JSSecButtonBase::SetFontColor);
|
||||
JSClass<JSSaveButton>::StaticMethod("backgroundColor", &JSSecButtonBase::SetBackgroundColor);
|
||||
JSClass<JSSaveButton>::StaticMethod("borderStyle", &JSSecButtonBase::SetBackgroundBorderStyle);
|
||||
JSClass<JSSaveButton>::StaticMethod("borderWidth", &JSSecButtonBase::SetBackgroundBorderWidth);
|
||||
JSClass<JSSaveButton>::StaticMethod("borderColor", &JSSecButtonBase::SetBackgroundBorderColor);
|
||||
JSClass<JSSaveButton>::StaticMethod("borderRadius", &JSSecButtonBase::SetBackgroundBorderRadius);
|
||||
JSClass<JSSaveButton>::StaticMethod("padding", &JSSecButtonBase::SetBackgroundPadding);
|
||||
JSClass<JSSaveButton>::StaticMethod("textIconSpace", &JSSecButtonBase::SetTextIconSpace);
|
||||
JSClass<JSSaveButton>::StaticMethod("onClick", &JSSaveButton::JsOnClick);
|
||||
JSClass<JSSaveButton>::StaticMethod("key", &JSViewAbstract::JsKey);
|
||||
JSClass<JSSaveButton>::StaticMethod("position", &JSViewAbstract::JsPosition);
|
||||
JSClass<JSSaveButton>::StaticMethod("markAnchor", &JSViewAbstract::JsMarkAnchor);
|
||||
JSClass<JSSaveButton>::StaticMethod("offset", &JSViewAbstract::JsOffset);
|
||||
JSClass<JSSaveButton>::StaticMethod("pop", &JSViewAbstract::Pop, opt);
|
||||
#if defined(PREVIEW)
|
||||
JSClass<JSSecSaveButton>::StaticMethod("debugLine", &JSViewAbstract::JsDebugLine);
|
||||
JSClass<JSSaveButton>::StaticMethod("debugLine", &JSViewAbstract::JsDebugLine);
|
||||
#endif
|
||||
JSClass<JSSecSaveButton>::Bind<>(globalObj);
|
||||
JSClass<JSSaveButton>::Bind<>(globalObj);
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_SAVE_BUTTON_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_SAVE_BUTTON_H
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SAVE_BUTTON_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SAVE_BUTTON_H
|
||||
|
||||
#include "bridge/declarative_frontend/engine/bindings.h"
|
||||
#include "bridge/declarative_frontend/engine/functions/js_function.h"
|
||||
@ -26,13 +26,13 @@
|
||||
#include "core/gestures/click_recognizer.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
class JsSecSaveButtonClickFunction : public JsFunction {
|
||||
DECLARE_ACE_TYPE(JsSecSaveButtonClickFunction, JsFunction)
|
||||
class JsSaveButtonClickFunction : public JsFunction {
|
||||
DECLARE_ACE_TYPE(JsSaveButtonClickFunction, JsFunction)
|
||||
public:
|
||||
explicit JsSecSaveButtonClickFunction(const JSRef<JSFunc>& jsFunction) :
|
||||
explicit JsSaveButtonClickFunction(const JSRef<JSFunc>& jsFunction) :
|
||||
JsFunction(JSRef<JSObject>(), jsFunction) {}
|
||||
|
||||
~JsSecSaveButtonClickFunction() override {};
|
||||
~JsSaveButtonClickFunction() override {};
|
||||
void Execute() override
|
||||
{
|
||||
JsFunction::ExecuteJS();
|
||||
@ -41,7 +41,7 @@ public:
|
||||
void Execute(GestureEvent& info);
|
||||
};
|
||||
|
||||
class JSSecSaveButton : public JSViewAbstract, public JSInteractableView {
|
||||
class JSSaveButton : public JSViewAbstract, public JSInteractableView {
|
||||
public:
|
||||
static void JSBind(BindingTarget globalObj);
|
||||
static bool ParseComponentStyle(const JSCallbackInfo& info, SaveButtonSaveDescription& text,
|
||||
@ -50,4 +50,4 @@ public:
|
||||
static void JsOnClick(const JSCallbackInfo& info);
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SEC_LOCATION_BUTTON_H
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_SAVE_BUTTON_H
|
@ -61,6 +61,8 @@ constexpr ScrollAlign ALIGN_TABLE[] = {
|
||||
ScrollAlign::AUTO,
|
||||
};
|
||||
|
||||
const std::regex DIMENSION_REGEX(R"(^[-+]?\d+(?:\.\d+)?(?:px|vp|fp|lpx)?$)", std::regex::icase);
|
||||
|
||||
} // namespace
|
||||
|
||||
void JSScroller::JSBind(BindingTarget globalObj)
|
||||
@ -100,8 +102,11 @@ void JSScroller::ScrollTo(const JSCallbackInfo& args)
|
||||
JSRef<JSObject> obj = JSRef<JSObject>::Cast(args[0]);
|
||||
Dimension xOffset;
|
||||
Dimension yOffset;
|
||||
if (!ConvertFromJSValue(obj->GetProperty("xOffset"), xOffset) ||
|
||||
!ConvertFromJSValue(obj->GetProperty("yOffset"), yOffset)) {
|
||||
auto xOffsetStr = obj->GetProperty("xOffset");
|
||||
auto yOffsetStr = obj->GetProperty("yOffset");
|
||||
if (!std::regex_match(xOffsetStr->ToString(), DIMENSION_REGEX) ||
|
||||
!std::regex_match(yOffsetStr->ToString(), DIMENSION_REGEX) || !ConvertFromJSValue(xOffsetStr, xOffset) ||
|
||||
!ConvertFromJSValue(yOffsetStr, yOffset)) {
|
||||
LOGW("Failed to parse param 'xOffset' or 'yOffset'");
|
||||
return;
|
||||
}
|
||||
|
@ -128,23 +128,6 @@ void JSSecButtonBase::SetLayoutDirection(const JSCallbackInfo& info)
|
||||
static_cast<SecurityComponentLayoutDirection>(value));
|
||||
}
|
||||
|
||||
void JSSecButtonBase::SetlayoutOrder(const JSCallbackInfo& info)
|
||||
{
|
||||
if (!info[0]->IsNumber()) {
|
||||
SecurityComponentModelNG::SetlayoutOrder(
|
||||
SecSecurityComponentLayoutOrder::ICON_FIRST);
|
||||
return;
|
||||
}
|
||||
int32_t value = info[0]->ToNumber<int32_t>();
|
||||
if ((value < static_cast<int32_t>(SecSecurityComponentLayoutOrder::ICON_FIRST)) ||
|
||||
(value > static_cast<int32_t>(SecSecurityComponentLayoutOrder::TEXT_FIRST))) {
|
||||
SecurityComponentModelNG::SetlayoutOrder(
|
||||
SecSecurityComponentLayoutOrder::ICON_FIRST);
|
||||
return;
|
||||
}
|
||||
SecurityComponentModelNG::SetlayoutOrder(static_cast<SecSecurityComponentLayoutOrder>(value));
|
||||
}
|
||||
|
||||
void JSSecButtonBase::SetBackgroundColor(const JSCallbackInfo& info)
|
||||
{
|
||||
auto theme = GetTheme<SecurityComponentTheme>();
|
||||
|
@ -35,7 +35,6 @@ public:
|
||||
static void SetFontFamily(const JSCallbackInfo& info);
|
||||
static void SetFontColor(const JSCallbackInfo& info);
|
||||
static void SetLayoutDirection(const JSCallbackInfo& info);
|
||||
static void SetlayoutOrder(const JSCallbackInfo& info);
|
||||
static void SetBackgroundColor(const JSCallbackInfo& info);
|
||||
static void SetBackgroundPadding(const JSCallbackInfo& info);
|
||||
static void SetTextIconSpace(const JSCallbackInfo& info);
|
||||
|
@ -427,7 +427,7 @@ SwiperParameters JSSwiper::GetDotIndicatorInfo(const JSRef<JSObject>& obj)
|
||||
bool parseOk = false;
|
||||
SwiperParameters swiperParameters;
|
||||
CalcDimension dimPosition;
|
||||
parseOk = ParseJsDimensionPx(leftValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(leftValue, dimPosition);
|
||||
if (parseOk) {
|
||||
if (dimPosition.ConvertToPx() < 0.0f) {
|
||||
dimPosition = 0.0_vp;
|
||||
@ -436,20 +436,20 @@ SwiperParameters JSSwiper::GetDotIndicatorInfo(const JSRef<JSObject>& obj)
|
||||
dimPosition = 0.0_vp;
|
||||
}
|
||||
swiperParameters.dimLeft = dimPosition;
|
||||
parseOk = ParseJsDimensionPx(topValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(topValue, dimPosition);
|
||||
swiperParameters.dimTop = parseOk ? dimPosition : 0.0_vp;
|
||||
parseOk = ParseJsDimensionPx(rightValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(rightValue, dimPosition);
|
||||
swiperParameters.dimRight = parseOk ? dimPosition : 0.0_vp;
|
||||
parseOk = ParseJsDimensionPx(bottomValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(bottomValue, dimPosition);
|
||||
swiperParameters.dimBottom = parseOk ? dimPosition : 0.0_vp;
|
||||
parseOk = ParseJsDimensionPx(itemWidthValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(itemWidthValue, dimPosition);
|
||||
auto defaultSize = swiperIndicatorTheme->GetSize();
|
||||
swiperParameters.itemWidth = parseOk && dimPosition > 0.0_vp ? dimPosition : defaultSize;
|
||||
parseOk = ParseJsDimensionPx(itemHeightValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(itemHeightValue, dimPosition);
|
||||
swiperParameters.itemHeight = parseOk && dimPosition > 0.0_vp ? dimPosition : defaultSize;
|
||||
parseOk = ParseJsDimensionPx(selectedItemWidthValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(selectedItemWidthValue, dimPosition);
|
||||
swiperParameters.selectedItemWidth = parseOk && dimPosition > 0.0_vp ? dimPosition : defaultSize;
|
||||
parseOk = ParseJsDimensionPx(selectedItemHeightValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(selectedItemHeightValue, dimPosition);
|
||||
swiperParameters.selectedItemHeight = parseOk && dimPosition > 0.0_vp ? dimPosition : defaultSize;
|
||||
if (maskValue->IsBoolean()) {
|
||||
auto mask = maskValue->ToBoolean();
|
||||
@ -684,15 +684,15 @@ void JSSwiper::SetIndicatorStyle(const JSCallbackInfo& info)
|
||||
auto swiperIndicatorTheme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
|
||||
CHECK_NULL_VOID(swiperIndicatorTheme);
|
||||
CalcDimension dimPosition;
|
||||
bool parseOk = ParseJsDimensionPx(leftValue, dimPosition);
|
||||
bool parseOk = ParseJsDimensionVp(leftValue, dimPosition);
|
||||
swiperParameters.dimLeft = parseOk ? dimPosition : 0.0_vp;
|
||||
parseOk = ParseJsDimensionPx(topValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(topValue, dimPosition);
|
||||
swiperParameters.dimTop = parseOk ? dimPosition : 0.0_vp;
|
||||
parseOk = ParseJsDimensionPx(rightValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(rightValue, dimPosition);
|
||||
swiperParameters.dimRight = parseOk ? dimPosition : 0.0_vp;
|
||||
parseOk = ParseJsDimensionPx(bottomValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(bottomValue, dimPosition);
|
||||
swiperParameters.dimBottom = parseOk ? dimPosition : 0.0_vp;
|
||||
parseOk = ParseJsDimensionPx(sizeValue, dimPosition);
|
||||
parseOk = ParseJsDimensionVp(sizeValue, dimPosition);
|
||||
SwiperModel::GetInstance()->SetIsIndicatorCustomSize(false);
|
||||
swiperParameters.itemWidth = parseOk && dimPosition > 0.0_vp ? dimPosition : swiperIndicatorTheme->GetSize();
|
||||
swiperParameters.itemHeight = parseOk && dimPosition > 0.0_vp ? dimPosition : swiperIndicatorTheme->GetSize();
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "core/components_ng/pattern/text/text_model.h"
|
||||
#include "core/components_ng/pattern/text/text_model_ng.h"
|
||||
#include "core/event/ace_event_handler.h"
|
||||
#include "core/pipeline/pipeline_base.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
@ -147,17 +148,14 @@ void JSText::SetFontSize(const JSCallbackInfo& info)
|
||||
LOGI("The argv is wrong, it is supposed to have at least 1 argument");
|
||||
return;
|
||||
}
|
||||
CalcDimension fontSize;
|
||||
if (!ParseJsDimensionFp(info[0], fontSize)) {
|
||||
return;
|
||||
}
|
||||
auto pipelineContext = PipelineBase::GetCurrentContext();
|
||||
CHECK_NULL_VOID_NOLOG(pipelineContext);
|
||||
auto theme = pipelineContext->GetTheme<TextTheme>();
|
||||
CHECK_NULL_VOID_NOLOG(theme);
|
||||
CalcDimension fontSize = theme->GetTextStyle().GetFontSize();
|
||||
ParseJsDimensionFp(info[0], fontSize);
|
||||
if (fontSize.IsNegative() || fontSize.Unit() == DimensionUnit::PERCENT) {
|
||||
auto pipelineContext = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID_NOLOG(pipelineContext);
|
||||
auto theme = pipelineContext->GetTheme<TextTheme>();
|
||||
CHECK_NULL_VOID_NOLOG(theme);
|
||||
TextModel::GetInstance()->SetFontSize(theme->GetTextStyle().GetFontSize());
|
||||
return;
|
||||
fontSize = theme->GetTextStyle().GetFontSize();
|
||||
}
|
||||
TextModel::GetInstance()->SetFontSize(fontSize);
|
||||
}
|
||||
@ -248,14 +246,8 @@ void JSText::SetTextOverflow(const JSCallbackInfo& info)
|
||||
|
||||
void JSText::SetMaxLines(const JSCallbackInfo& info)
|
||||
{
|
||||
int32_t value;
|
||||
if (info[0]->ToString() == "Infinity") {
|
||||
value = Infinity<uint32_t>();
|
||||
} else if (!info[0]->IsNumber()) {
|
||||
return;
|
||||
} else {
|
||||
ParseJsInt32(info[0], value);
|
||||
}
|
||||
int32_t value = Infinity<uint32_t>();
|
||||
ParseJsInt32(info[0], value);
|
||||
TextModel::GetInstance()->SetMaxLines(value);
|
||||
}
|
||||
|
||||
@ -335,9 +327,7 @@ void JSText::SetMinFontSize(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
CalcDimension fontSize;
|
||||
if (!ParseJsDimensionFp(info[0], fontSize)) {
|
||||
return;
|
||||
}
|
||||
ParseJsDimensionFp(info[0], fontSize);
|
||||
TextModel::GetInstance()->SetAdaptMinFontSize(fontSize);
|
||||
}
|
||||
|
||||
@ -348,9 +338,7 @@ void JSText::SetMaxFontSize(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
CalcDimension fontSize;
|
||||
if (!ParseJsDimensionFp(info[0], fontSize)) {
|
||||
return;
|
||||
}
|
||||
ParseJsDimensionFp(info[0], fontSize);
|
||||
TextModel::GetInstance()->SetAdaptMaxFontSize(fontSize);
|
||||
}
|
||||
|
||||
@ -399,23 +387,18 @@ void JSText::SetDecoration(const JSCallbackInfo& info)
|
||||
JSRef<JSObject> obj = JSRef<JSObject>::Cast(info[0]);
|
||||
JSRef<JSVal> typeValue = obj->GetProperty("type");
|
||||
JSRef<JSVal> colorValue = obj->GetProperty("color");
|
||||
|
||||
std::optional<TextDecoration> textDecoration;
|
||||
auto pipelineContext = PipelineBase::GetCurrentContext();
|
||||
CHECK_NULL_VOID_NOLOG(pipelineContext);
|
||||
auto theme = pipelineContext->GetTheme<TextTheme>();
|
||||
CHECK_NULL_VOID_NOLOG(theme);
|
||||
TextDecoration textDecoration = theme->GetTextStyle().GetTextDecoration();
|
||||
if (typeValue->IsNumber()) {
|
||||
textDecoration = static_cast<TextDecoration>(typeValue->ToNumber<int32_t>());
|
||||
}
|
||||
std::optional<Color> colorVal;
|
||||
Color result;
|
||||
if (ParseJsColor(colorValue, result)) {
|
||||
colorVal = result;
|
||||
}
|
||||
|
||||
if (textDecoration) {
|
||||
TextModel::GetInstance()->SetTextDecoration(textDecoration.value());
|
||||
}
|
||||
if (colorVal) {
|
||||
TextModel::GetInstance()->SetTextDecorationColor(colorVal.value());
|
||||
}
|
||||
Color result = theme->GetTextStyle().GetTextDecorationColor();
|
||||
ParseJsColor(colorValue, result);
|
||||
TextModel::GetInstance()->SetTextDecoration(textDecoration);
|
||||
TextModel::GetInstance()->SetTextDecorationColor(result);
|
||||
} while (false);
|
||||
info.SetReturnValue(info.This());
|
||||
}
|
||||
|
@ -194,13 +194,10 @@ void JSTextField::SetPlaceholderColor(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
|
||||
Color color;
|
||||
if (!CheckColor(info[0], color, V2::TEXTINPUT_ETS_TAG, "PlaceholderColor")) {
|
||||
auto theme = GetTheme<TextFieldTheme>();
|
||||
if (info[0]->IsUndefined() && theme) {
|
||||
color = theme->GetPlaceholderColor();
|
||||
}
|
||||
}
|
||||
auto theme = GetTheme<TextFieldTheme>();
|
||||
CHECK_NULL_VOID(theme);
|
||||
Color color = theme->GetPlaceholderColor();
|
||||
CheckColor(info[0], color, V2::TEXTINPUT_ETS_TAG, "PlaceholderColor");
|
||||
TextFieldModel::GetInstance()->SetPlaceholderColor(color);
|
||||
}
|
||||
|
||||
@ -1008,6 +1005,10 @@ void JSTextField::SetMaxLines(const JSCallbackInfo& info)
|
||||
TextFieldModel::GetInstance()->SetMaxViewLines(MAX_LINES);
|
||||
return;
|
||||
}
|
||||
if (info[0]->ToNumber<int32_t>() <= 0) {
|
||||
TextFieldModel::GetInstance()->SetMaxViewLines(MAX_LINES);
|
||||
return;
|
||||
}
|
||||
TextFieldModel::GetInstance()->SetMaxViewLines(info[0]->ToNumber<uint32_t>());
|
||||
}
|
||||
|
||||
|
@ -722,20 +722,22 @@ bool JSTextPickerParser::ParseIconTextArray(
|
||||
void JSTextPickerParser::ParseTextStyle(const JSRef<JSObject>& paramObj, NG::PickerTextStyle& textStyle)
|
||||
{
|
||||
auto fontColor = paramObj->GetProperty("color");
|
||||
auto fontStyle = paramObj->GetProperty("font");
|
||||
auto fontOptions = paramObj->GetProperty("font");
|
||||
|
||||
Color textColor;
|
||||
if (ParseJsColor(fontColor, textColor)) {
|
||||
textStyle.textColor = textColor;
|
||||
}
|
||||
|
||||
if (!fontStyle->IsObject()) {
|
||||
if (!fontOptions->IsObject()) {
|
||||
LOGE("fontStyle is not obj.");
|
||||
return;
|
||||
}
|
||||
JSRef<JSObject> fontObj = JSRef<JSObject>::Cast(fontStyle);
|
||||
JSRef<JSObject> fontObj = JSRef<JSObject>::Cast(fontOptions);
|
||||
auto fontSize = fontObj->GetProperty("size");
|
||||
auto fontWeight = fontObj->GetProperty("weight");
|
||||
auto fontFamily = fontObj->GetProperty("family");
|
||||
auto fontStyle = fontObj->GetProperty("style");
|
||||
if (fontSize->IsNull() || fontSize->IsUndefined()) {
|
||||
textStyle.fontSize = Dimension(-1);
|
||||
} else {
|
||||
@ -757,6 +759,22 @@ void JSTextPickerParser::ParseTextStyle(const JSRef<JSObject>& paramObj, NG::Pic
|
||||
}
|
||||
textStyle.fontWeight = ConvertStrToFontWeight(weight);
|
||||
}
|
||||
|
||||
if (!fontFamily->IsNull() && !fontFamily->IsUndefined()) {
|
||||
std::vector<std::string> families;
|
||||
if (ParseJsFontFamilies(fontFamily, families)) {
|
||||
textStyle.fontFamily = families;
|
||||
}
|
||||
}
|
||||
|
||||
if (fontStyle->IsNumber()) {
|
||||
auto style = fontStyle->ToNumber<int32_t>();
|
||||
if (style < 0 || style > 1) {
|
||||
LOGE("Text fontStyle(%d) is invalid value", style);
|
||||
return;
|
||||
}
|
||||
textStyle.fontStyle = static_cast<FontStyle>(style);
|
||||
}
|
||||
}
|
||||
|
||||
void JSTextPicker::SetDefaultPickerItemHeight(const JSCallbackInfo& info)
|
||||
@ -1216,7 +1234,6 @@ bool JSTextPickerDialog::ParseShowDataAttribute(
|
||||
const JSRef<JSObject>& paramObject, NG::TextPickerSettingData& settingData)
|
||||
{
|
||||
CalcDimension height;
|
||||
NG::PickerTextProperties textProperties;
|
||||
auto defaultHeight = paramObject->GetProperty("defaultPickerItemHeight");
|
||||
if (defaultHeight->IsNumber() || defaultHeight->IsString()) {
|
||||
if (!JSViewAbstract::ParseJsDimensionFp(defaultHeight, height)) {
|
||||
@ -1224,12 +1241,7 @@ bool JSTextPickerDialog::ParseShowDataAttribute(
|
||||
}
|
||||
}
|
||||
settingData.height = height;
|
||||
ParseTextProperties(paramObject, textProperties);
|
||||
if (memcpy_s(&settingData.properties, sizeof(NG::PickerTextProperties), &textProperties,
|
||||
sizeof(NG::PickerTextProperties)) != EOK) {
|
||||
LOGE("memcpy properties error.");
|
||||
return false;
|
||||
}
|
||||
ParseTextProperties(paramObject, settingData.properties);
|
||||
return true;
|
||||
}
|
||||
bool JSTextPickerDialog::ParseCanLoop(const JSRef<JSObject>& paramObject, bool& canLoop)
|
||||
|
@ -1993,6 +1993,39 @@ void JSViewAbstract::JsBackgroundBlurStyle(const JSCallbackInfo& info)
|
||||
ViewAbstractModel::GetInstance()->SetBackgroundBlurStyle(styleOption);
|
||||
}
|
||||
|
||||
void JSViewAbstract::JsBackgroundEffect(const JSCallbackInfo& info)
|
||||
{
|
||||
if (info.Length() == 0) {
|
||||
LOGW("The arg of backgroundBlurStyle is wrong, it is supposed to have 1 argument");
|
||||
return;
|
||||
}
|
||||
if (!info[0]->IsObject()) {
|
||||
LOGW("failed to set background effect.");
|
||||
return;
|
||||
}
|
||||
JSRef<JSObject> jsOption = JSRef<JSObject>::Cast(info[0]);
|
||||
CalcDimension radius;
|
||||
if (!ParseJsDimensionVp(jsOption->GetProperty("radius"), radius) || LessNotEqual(radius.Value(), 0.0f)) {
|
||||
radius.SetValue(0.0f);
|
||||
}
|
||||
double saturation = 1.0f;
|
||||
if (jsOption->GetProperty("saturation")->IsNumber()) {
|
||||
saturation = jsOption->GetProperty("saturation")->ToNumber<double>();
|
||||
saturation = saturation > 0.0f ? saturation : 1.0f;
|
||||
}
|
||||
double brightness = 1.0f;
|
||||
if (jsOption->GetProperty("brightness")->IsNumber()) {
|
||||
brightness = jsOption->GetProperty("brightness")->ToNumber<double>();
|
||||
brightness = brightness > 0.0f ? brightness : 1.0f;
|
||||
}
|
||||
Color color = Color::TRANSPARENT;
|
||||
if (!ParseJsColor(jsOption->GetProperty("color"), color)) {
|
||||
color.SetValue(Color::TRANSPARENT.GetValue());
|
||||
}
|
||||
EffectOption option = {radius, saturation, brightness, color};
|
||||
ViewAbstractModel::GetInstance()->SetBackgroundEffect(option);
|
||||
}
|
||||
|
||||
void JSViewAbstract::JsForegroundBlurStyle(const JSCallbackInfo& info)
|
||||
{
|
||||
if (info.Length() == 0) {
|
||||
@ -5355,6 +5388,7 @@ void JSViewAbstract::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSViewAbstract>::StaticMethod("backgroundImageSize", &JSViewAbstract::JsBackgroundImageSize);
|
||||
JSClass<JSViewAbstract>::StaticMethod("backgroundImagePosition", &JSViewAbstract::JsBackgroundImagePosition);
|
||||
JSClass<JSViewAbstract>::StaticMethod("backgroundBlurStyle", &JSViewAbstract::JsBackgroundBlurStyle);
|
||||
JSClass<JSViewAbstract>::StaticMethod("backgroundEffect", &JSViewAbstract::JsBackgroundEffect);
|
||||
JSClass<JSViewAbstract>::StaticMethod("foregroundBlurStyle", &JSViewAbstract::JsForegroundBlurStyle);
|
||||
JSClass<JSViewAbstract>::StaticMethod("lightUpEffect", &JSViewAbstract::JsLightUpEffect);
|
||||
JSClass<JSViewAbstract>::StaticMethod("sphericalEffect", &JSViewAbstract::JsSphericalEffect);
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
static void JsBackgroundImageSize(const JSCallbackInfo& info);
|
||||
static void JsBackgroundImagePosition(const JSCallbackInfo& info);
|
||||
static void JsBackgroundBlurStyle(const JSCallbackInfo& info);
|
||||
static void JsBackgroundEffect(const JSCallbackInfo& info);
|
||||
static void JsForegroundBlurStyle(const JSCallbackInfo& info);
|
||||
static void JsSphericalEffect(const JSCallbackInfo& info);
|
||||
static void JsPixelStretchEffect(const JSCallbackInfo& info);
|
||||
|
@ -92,7 +92,8 @@ void DatePickerModelImpl::SetBackgroundColor(const Color& color)
|
||||
|
||||
void DatePickerDialogModelImpl::SetDatePickerDialogShow(PickerDialogInfo& pickerDialog,
|
||||
NG::DatePickerSettingData& settingData, std::function<void()>&& onCancel,
|
||||
std::function<void(const std::string&)>&& onAccept, std::function<void(const std::string&)>&& onChange,
|
||||
std::function<void(const std::string&)>&& onAccept, std::function<void(const std::string&)>&& onDateAccept,
|
||||
std::function<void(const std::string&)>&& onDateChange, std::function<void(const std::string&)>&& onChange,
|
||||
DatePickerType pickerType)
|
||||
{
|
||||
std::string name;
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
void SetSelectedTime(const PickerTime& selectedTime) override;
|
||||
void SetHour24(bool value) override;
|
||||
void SetOnChange(DateChangeEvent&& onChange) override;
|
||||
void SetOnDateChange(DateChangeEvent&& onChange) override {}
|
||||
void SetDisappearTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) override {};
|
||||
void SetNormalTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) override {};
|
||||
void SetSelectedTextStyle(const RefPtr<PickerTheme>& theme, const NG::PickerTextStyle& value) override {};
|
||||
@ -44,7 +45,8 @@ class DatePickerDialogModelImpl : public DatePickerDialogModel {
|
||||
public:
|
||||
void SetDatePickerDialogShow(PickerDialogInfo& pickerDialog, NG::DatePickerSettingData& settingData,
|
||||
std::function<void()>&& onCancel, std::function<void(const std::string&)>&& onAccept,
|
||||
std::function<void(const std::string&)>&& onChange, DatePickerType pickerType) override;
|
||||
std::function<void(const std::string&)>&& onChange, std::function<void(const std::string&)>&& onDateAccept,
|
||||
std::function<void(const std::string&)>&& onDateChange, DatePickerType pickerType) override;
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_PICKER_MODEL_IMPL_H
|
||||
|
@ -44,7 +44,12 @@ void JSWindowScene::Create(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
|
||||
auto persistentId = static_cast<uint64_t>(info[0]->ToNumber<double>());
|
||||
double value = info[0]->ToNumber<double>();
|
||||
if (value < 0 || value > std::numeric_limits<int32_t>::max()) {
|
||||
LOGE("input info[0] is beyond the int32_t limit");
|
||||
value = 0;
|
||||
}
|
||||
auto persistentId = static_cast<int32_t>(value);
|
||||
NG::WindowSceneModel::Create(persistentId);
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -41,6 +41,7 @@ bool DeclarativeFrontendNG::Initialize(FrontendType type, const RefPtr<TaskExecu
|
||||
{
|
||||
LOGI("DeclarativeFrontendNG initialize begin.");
|
||||
type_ = type;
|
||||
taskExecutor_ = taskExecutor;
|
||||
ACE_DCHECK(type_ == FrontendType::DECLARATIVE_JS);
|
||||
InitializeDelegate(taskExecutor);
|
||||
bool needPostJsTask = true;
|
||||
@ -61,7 +62,6 @@ bool DeclarativeFrontendNG::Initialize(FrontendType type, const RefPtr<TaskExecu
|
||||
} else {
|
||||
initJSEngineTask();
|
||||
}
|
||||
taskExecutor_ = taskExecutor;
|
||||
LOGI("DeclarativeFrontendNG initialize end.");
|
||||
return true;
|
||||
}
|
||||
|
@ -116,11 +116,6 @@ public:
|
||||
RefPtr<AceEventHandler> GetEventHandler() override
|
||||
{
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
FrontendType GetType() override
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
// judge frontend is foreground frontend.
|
||||
@ -192,11 +187,9 @@ public:
|
||||
private:
|
||||
void InitializeDelegate(const RefPtr<TaskExecutor>& taskExecutor);
|
||||
|
||||
FrontendType type_ = FrontendType::DECLARATIVE_JS;
|
||||
RefPtr<Framework::JsEngine> jsEngine_;
|
||||
RefPtr<Framework::FrontendDelegateDeclarativeNG> delegate_;
|
||||
RefPtr<AccessibilityManager> accessibilityManager_;
|
||||
RefPtr<TaskExecutor> taskExecutor_;
|
||||
|
||||
std::string pageProfile_;
|
||||
bool foregroundFrontend_ = false;
|
||||
|
@ -250,7 +250,7 @@ void PageRouterManager::ReplaceNamedRoute(const RouterPageInfo& target)
|
||||
void PageRouterManager::BackWithTarget(const RouterPageInfo& target)
|
||||
{
|
||||
CHECK_RUN_ON(JS);
|
||||
LOGD("router.Back path = %{private}s", target.url.c_str());
|
||||
LOGI("router.Back path = %{private}s", target.url.c_str());
|
||||
if (inRouterOpt_) {
|
||||
LOGI("in router opt, post back router task");
|
||||
auto context = PipelineContext::GetCurrentContext();
|
||||
@ -351,6 +351,7 @@ void PageRouterManager::StartClean()
|
||||
bool PageRouterManager::Pop()
|
||||
{
|
||||
CHECK_RUN_ON(JS);
|
||||
LOGI("router pop be called");
|
||||
if (inRouterOpt_) {
|
||||
LOGE("in router opt, post Pop router task failed");
|
||||
return false;
|
||||
@ -646,8 +647,8 @@ void PageRouterManager::PushOhmUrl(const RouterPageInfo& target)
|
||||
CHECK_NULL_VOID(pageUrlChecker);
|
||||
auto taskExecutor = container->GetTaskExecutor();
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostTask(
|
||||
[pageUrlChecker, target]() { pageUrlChecker->CheckPreload(target.url); }, TaskExecutor::TaskType::BACKGROUND);
|
||||
taskExecutor->PostTask([pageUrlChecker, url = target.url]() { pageUrlChecker->CheckPreload(url); },
|
||||
TaskExecutor::TaskType::BACKGROUND);
|
||||
}
|
||||
|
||||
void PageRouterManager::StartPush(const RouterPageInfo& target)
|
||||
@ -747,8 +748,8 @@ void PageRouterManager::ReplaceOhmUrl(const RouterPageInfo& target)
|
||||
CHECK_NULL_VOID(pageUrlChecker);
|
||||
auto taskExecutor = container->GetTaskExecutor();
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostTask(
|
||||
[pageUrlChecker, target]() { pageUrlChecker->CheckPreload(target.url); }, TaskExecutor::TaskType::BACKGROUND);
|
||||
taskExecutor->PostTask([pageUrlChecker, url = target.url]() { pageUrlChecker->CheckPreload(url); },
|
||||
TaskExecutor::TaskType::BACKGROUND);
|
||||
}
|
||||
|
||||
void PageRouterManager::StartReplace(const RouterPageInfo& target)
|
||||
|
@ -49,3 +49,31 @@ class stateMgmtTrace {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class errorReport {
|
||||
public static varValueCheckFailed<T>(params : { customComponent : string, variableDeco: string, variableName: string, expectedType: string, value : T }) : void {
|
||||
let msg = `@Component '${params.customComponent}': Illegal variable value error with decorated variable ${params.variableDeco} '${params.variableName}': `;
|
||||
msg += `failed validation: '${params.expectedType}`;
|
||||
try {
|
||||
msg += `, attempt to assign value type: '${typeof params.value}'`;
|
||||
msg += `, value: '${JSON.stringify(params.value, null, 4)}'`;
|
||||
} catch(e) {}
|
||||
|
||||
msg += "!";
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
|
||||
public static varObservationFailed<T>(params : { customComponent : string, variableDeco: string, variableName: string, value: T }) : void {
|
||||
let msg = `@Component '${params.customComponent}': decorated variable ${params.variableDeco} '${params.variableName}': `;
|
||||
msg += `its class is neither decorated with '@Observed' nor it is an instance of 'SubscribableAbstract'`;
|
||||
|
||||
try {
|
||||
msg += `, attempt to assign value type: '${typeof params.value}'`;
|
||||
msg += `, value: '${JSON.stringify(params.value, null, 4)}'`;
|
||||
} catch(e) {}
|
||||
|
||||
msg += "!";
|
||||
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
}
|
@ -24,9 +24,8 @@
|
||||
* property.
|
||||
*/
|
||||
|
||||
class ObservedPropertyObjectPU<T extends Object> extends ObservedPropertyObjectAbstractPU<T>
|
||||
implements PeerChangeEventReceiverPU<T>,
|
||||
ObservedObjectEventsPUReceiver<T> {
|
||||
class ObservedPropertyPU<T> extends ObservedPropertyAbstractPU<T>
|
||||
implements PeerChangeEventReceiverPU<T>, ObservedObjectEventsPUReceiver<T> {
|
||||
|
||||
private wrappedValue_: T;
|
||||
|
||||
@ -42,6 +41,7 @@ class ObservedPropertyObjectPU<T extends Object> extends ObservedPropertyObjectA
|
||||
super.aboutToBeDeleted();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by a SynchedPropertyObjectTwoWayPU (@Link, @Consume) that uses this as sync peer when it has changed
|
||||
* @param eventSource
|
||||
@ -77,31 +77,28 @@ class ObservedPropertyObjectPU<T extends Object> extends ObservedPropertyObjectA
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
actually update this.wrappedValue_
|
||||
called needs to do value change check
|
||||
and also notify with this.aboutToChange();
|
||||
*/
|
||||
private setValueInternal(newValue: T): boolean {
|
||||
if (newValue == undefined || newValue == null) {
|
||||
stateMgmtConsole.error(`ObservedPropertyObjectPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @State/@Provide value must not be undefined or null. Application error!`);
|
||||
// TODO enable support for undefined and null
|
||||
// unsubscribe old value, set wrappedValue_ to null/undefined
|
||||
}
|
||||
if (typeof newValue !== 'object') {
|
||||
stateMgmtConsole.debug(`ObservedPropertyObject[${this.id__()}, '${this.info() || "unknown"}'] new value is NOT an object. Application error. Ignoring set.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newValue == this.wrappedValue_) {
|
||||
stateMgmtConsole.debug(`ObservedPropertyObjectPU[${this.id__()}, '${this.info() || "unknown"}'] newValue unchanged`);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.unsubscribeWrappedObject();
|
||||
if (!this.checkIsSupportedValue(newValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newValue instanceof SubscribableAbstract) {
|
||||
this.unsubscribeWrappedObject();
|
||||
if (!newValue || typeof newValue !== 'object') {
|
||||
// undefined, null, simple type:
|
||||
// nothing to subscribe to in case of new value undefined || null || simple type
|
||||
this.wrappedValue_ = newValue;
|
||||
} else if (newValue instanceof SubscribableAbstract) {
|
||||
stateMgmtConsole.debug(`ObservedPropertyObjectPU[${this.id__()}, '${this.info() || "unknown"}'] new value is an SubscribableAbstract, subscribiung to it.`);
|
||||
this.wrappedValue_ = newValue;
|
||||
(this.wrappedValue_ as unknown as SubscribableAbstract).addOwningProperty(this);
|
||||
@ -139,3 +136,12 @@ class ObservedPropertyObjectPU<T extends Object> extends ObservedPropertyObjectA
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// class definitions for backward compatibility
|
||||
class ObservedPropertyObjectPU<T> extends ObservedPropertyPU<T> {
|
||||
|
||||
}
|
||||
|
||||
class ObservedPropertySimplePU<T> extends ObservedPropertyPU<T> {
|
||||
|
||||
}
|
@ -174,6 +174,81 @@ implements ISinglePropertyChangeSubscriber<T>, IMultiPropertiesChangeSubscriber,
|
||||
return this.subscriberRefs_.size + (this.owningView_ ? 1 : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
type checking for any supported type, as required for union type support
|
||||
see 1st parameter for explanation what is allowed
|
||||
|
||||
FIXME this expects the Map, Set patch to go in
|
||||
*/
|
||||
|
||||
protected checkIsSupportedValue(value: T): boolean {
|
||||
return this.checkNewValue(
|
||||
`undefined, null, number, boolean, string, or Object but not function`,
|
||||
value,
|
||||
() => ((typeof value == "object" && typeof value != "function")
|
||||
|| typeof value == "number" || typeof value == "string" || typeof value == "boolean")
|
||||
|| (value == undefined || value == null)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
type checking for allowed Object type value
|
||||
see 1st parameter for explanation what is allowed
|
||||
|
||||
FIXME this expects the Map, Set patch to go in
|
||||
*/
|
||||
protected checkIsObject(value: T): boolean {
|
||||
return this.checkNewValue(
|
||||
`undefined, null, Object including Array and instance of SubscribableAbstract and excluding function, Set, and Map`,
|
||||
value,
|
||||
() => (value == undefined || value == null || (typeof value == "object"))
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
type checking for allowed simple types value
|
||||
see 1st parameter for explanation what is allowed
|
||||
*/
|
||||
protected checkIsSimple(value: T): boolean {
|
||||
return this.checkNewValue(
|
||||
`undefined, number, boolean, string`,
|
||||
value,
|
||||
() => (value == undefined || typeof value == "number" || typeof value == "string" || typeof value == "boolean")
|
||||
);
|
||||
}
|
||||
|
||||
private static readonly mapDeco = new Map<string, string>([
|
||||
["ObservedPropertyObjectPU", "@State/@Provide"],
|
||||
["ObservedPropertySimplePU", "@State/@Provide (error, should not be used)"],
|
||||
["SynchedPropertyObjectOneWayPU", "@Prop"],
|
||||
["SynchedPropertySimpleOneWayPU", "@Prop (error, should not be used)"],
|
||||
["SynchedPropertyObjectTwoWayPU", "@Link/@Consume"],
|
||||
["SynchedPropertySimpleTwoWayPU", "@Link/@Consume (error, should not be used)"],
|
||||
["SynchedPropertyNestedObjectPU", "@ObjectLink (only class-objects supported"],
|
||||
["SynchedPropertyNesedObjectPU", "@ObjectLink (only class-objects supported"]
|
||||
]);
|
||||
|
||||
protected checkNewValue(isAllowedComment : string, newValue: T, validator: (value: T) => boolean) : boolean {
|
||||
if (validator(newValue)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// report error
|
||||
// current implementation throws an Exception
|
||||
errorReport.varValueCheckFailed({
|
||||
customComponent: this.owningView_? this.owningView_.constructor.name : "unknown owningView / internal error",
|
||||
variableDeco: ObservedPropertyAbstractPU.mapDeco.get(this.constructor.name),
|
||||
variableName: this.info(),
|
||||
expectedType: isAllowedComment,
|
||||
value: newValue
|
||||
});
|
||||
|
||||
// never gets here if errorReport.varValueCheckFailed throws an exception
|
||||
// but should nto depend on its implementation
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* factory function for concrete 'object' or 'simple' ObservedProperty object
|
||||
* depending if value is Class object
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ObservedPropertyObjectAbstractPU
|
||||
*
|
||||
* common bbase class of ObservedPropertyObjectPU and
|
||||
* SyncedObjectPropertyTwoWayPU
|
||||
* adds the createObjectLink to the ObservedPropertyAbstract base
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
|
||||
abstract class ObservedPropertyObjectAbstractPU<C extends Object>
|
||||
extends ObservedPropertyAbstractPU<C> {
|
||||
|
||||
constructor(owningView: IPropertySubscriber, thisPropertyName: PropertyInfo) {
|
||||
super(owningView, thisPropertyName)
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ObservedPropertySimplePU
|
||||
* implementation of @State and @Provide decorated variables of types (T=) boolean | number | string | enum
|
||||
*
|
||||
* Holds an actual property value of type T
|
||||
* uses its base class to manage subscribers to this
|
||||
* property.
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class ObservedPropertySimplePU<T> extends ObservedPropertySimpleAbstractPU<T>
|
||||
implements ISinglePropertyChangeSubscriber<T>, PeerChangeEventReceiverPU<T> {
|
||||
|
||||
private wrappedValue_: T;
|
||||
|
||||
constructor(localInitValue: T, owningView: IPropertySubscriber, propertyName: PropertyInfo) {
|
||||
super(owningView, propertyName);
|
||||
|
||||
// TODO undefined and null support remove this if statement
|
||||
if (typeof localInitValue === "object") {
|
||||
throw new SyntaxError("ObservedPropertySimple constructor: @State/@Provide value must not be an object")!
|
||||
}
|
||||
|
||||
this.setValueInternal(localInitValue);
|
||||
}
|
||||
|
||||
aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber) {
|
||||
this.removeSubscriber(unsubscribeMe);
|
||||
super.aboutToBeDeleted();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by a @Link - SynchedPropertySimpleTwoWay that uses this as sync peer when it has changed
|
||||
* @param eventSource
|
||||
*/
|
||||
syncPeerHasChanged(eventSource: ObservedPropertyAbstractPU<T>) {
|
||||
stateMgmtConsole.debug(`ObservedPropertySimple[${this.id__()}, '${this.info() || "unknown"}']: syncPeerHasChanged peer '${eventSource.info()}'.`);
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
|
||||
/*
|
||||
actually update this.wrappedValue_
|
||||
called needs to do value change check
|
||||
and also notify with this.aboutToChange();
|
||||
*/
|
||||
private setValueInternal(newValue: T): boolean {
|
||||
stateMgmtConsole.debug(`ObservedPropertySimplePU[${this.id__()}, '${this.info() || "unknown"}'] set new value`);
|
||||
if (this.wrappedValue_ != newValue) {
|
||||
this.wrappedValue_ = newValue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public getUnmonitored(): T {
|
||||
stateMgmtConsole.debug(`ObservedPropertySimple[${this.id__()}, '${this.info() || "unknown"}']: getUnmonitored.`);
|
||||
// unmonitored get access , no call to notifyPropertyRead !
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
|
||||
public get(): T {
|
||||
stateMgmtConsole.debug(`ObservedPropertySimple[${this.id__()}, '${this.info() || "unknown"}']: get.`);
|
||||
this.notifyPropertyHasBeenReadPU()
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
|
||||
public set(newValue: T): void {
|
||||
if (this.wrappedValue_ == newValue) {
|
||||
stateMgmtConsole.debug(`ObservedPropertySimple[${this.id__()}, '${this.info() || "unknown"}']: set with unchanged value - ignoring.`);
|
||||
return;
|
||||
}
|
||||
stateMgmtConsole.debug(`ObservedPropertySimple[${this.id__()}, '${this.info() || "unknown"}']: set changed value.`);
|
||||
if (this.setValueInternal(newValue)) {
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
*
|
||||
*/
|
||||
class SynchedPropertyNestedObjectPU<C extends Object>
|
||||
extends ObservedPropertyObjectAbstractPU<C>
|
||||
extends ObservedPropertyAbstractPU<C>
|
||||
implements ObservedObjectEventsPUReceiver<C> {
|
||||
|
||||
private obsObject_: C;
|
||||
@ -39,7 +39,6 @@ class SynchedPropertyNestedObjectPU<C extends Object>
|
||||
owningChildView: IPropertySubscriber, propertyName: PropertyInfo) {
|
||||
super(owningChildView, propertyName);
|
||||
this.obsObject_ = obsObject;
|
||||
|
||||
this.setValueInternal(obsObject);
|
||||
}
|
||||
|
||||
@ -87,14 +86,19 @@ class SynchedPropertyNestedObjectPU<C extends Object>
|
||||
}
|
||||
|
||||
stateMgmtConsole.debug(`SynchedPropertyNestedObjectPU[${this.id__()}, '${this.info() || "unknown"}']: set: @ObjectLink set to new value: .`);
|
||||
this.setValueInternal(newValue);
|
||||
|
||||
// notify value change to subscribing View
|
||||
this.notifyPropertyHasChangedPU();
|
||||
if (this.setValueInternal(newValue)) {
|
||||
// notify value change to subscribing View
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private setValueInternal(newValue: C): void {
|
||||
private setValueInternal(newValue: C): boolean {
|
||||
if (!this.checkIsObject(newValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.obsObject_ != undefined) {
|
||||
if (this.obsObject_ instanceof SubscribableAbstract) {
|
||||
// unregister from SubscribableAbstract object
|
||||
@ -119,6 +123,7 @@ class SynchedPropertyNestedObjectPU<C extends Object>
|
||||
value changes will bot be observed and UI will not update. forgot @Observed class decorator? Application error.`);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,32 +45,31 @@
|
||||
*
|
||||
* 1- assignment of a new Object value: this.aProp = new ClassA()
|
||||
* rhs can be ObservedObject because of @Observed decoration or now
|
||||
* notifyPropertryHasChangedPU
|
||||
* notifyPropertyHasChangedPU
|
||||
*
|
||||
* 2- local ObservedObject member property change
|
||||
* objectPropertyHasChangedPU called, eventSource is the ObservedObject stored in localCopyObservedObject_
|
||||
* no need to copy, notifyPropertryHasChangedPU
|
||||
* no need to copy, notifyPropertyHasChangedPU
|
||||
*
|
||||
* 3- Rerender of the custom component triggered from the parent
|
||||
* reset() is called (code generated by the transpiler), set the value of source_ , if that causes a change will call syncPeerHasChanged
|
||||
* syncPeerHasChanged need to deep copy the ObservedObject from source to localCopyObservedObject_
|
||||
* notifyPropertryHasChangedPU
|
||||
* notifyPropertyHasChangedPU
|
||||
*
|
||||
* 4- source_ ObservedObject member property change
|
||||
* objectPropertyHasChangedPU called, eventSource is the ObservedObject stored source_.getUnmonitored
|
||||
* notifyPropertryHasChangedPU
|
||||
* notifyPropertyHasChangedPU
|
||||
*/
|
||||
class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
extends ObservedPropertyObjectAbstractPU<C>
|
||||
implements PeerChangeEventReceiverPU<C>,
|
||||
ObservedObjectEventsPUReceiver<C> {
|
||||
|
||||
|
||||
class SynchedPropertyOneWayPU<C> extends ObservedPropertyAbstractPU<C>
|
||||
implements PeerChangeEventReceiverPU<C>, ObservedObjectEventsPUReceiver<C> {
|
||||
|
||||
// the locally modified ObservedObject
|
||||
private localCopyObservedObject_: C;
|
||||
|
||||
// reference to the source variable in parent component
|
||||
private source_: ObservedPropertyAbstract<C>;
|
||||
|
||||
// true for @Prop code path,
|
||||
// false for @(Local)StorageProp
|
||||
private sourceIsOwnObject : boolean;
|
||||
@ -88,16 +87,19 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
// subscribe to receive value change updates from LocalStorage source property
|
||||
this.source_.addSubscriber(this);
|
||||
} else {
|
||||
// code path for
|
||||
// 1- source is of same type C in parent, source is its value, not the backing store ObservedPropertyObject
|
||||
// 2- nested Object/Array inside observed another object/array in parent, source is its value
|
||||
if (!((source instanceof SubscribableAbstract) || ObservedObject.IsObservedObject(source))) {
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Provided source object's class
|
||||
lacks @Observed class decorator. Object property changes will not be observed.`);
|
||||
const sourceValue = source as C;
|
||||
if (this.checkIsSupportedValue(sourceValue)) {
|
||||
// code path for
|
||||
// 1- source is of same type C in parent, source is its value, not the backing store ObservedPropertyObject
|
||||
// 2- nested Object/Array inside observed another object/array in parent, source is its value
|
||||
if (!((sourceValue instanceof SubscribableAbstract) || ObservedObject.IsObservedObject(sourceValue))) {
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Provided source object's class is not instance of SubscribableAbstract,
|
||||
it also lacks @Observed class decorator. Object property changes will not be observed.`);
|
||||
}
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Prop wrapping source in a new ObservedPropertyObjectPU`);
|
||||
this.source_ = new ObservedPropertyObjectPU<C>(sourceValue, this, this.getSourceObservedPropertyFakeName());
|
||||
this.sourceIsOwnObject = true;
|
||||
}
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Prop wrapping source in a new ObservedPropertyObjectPU`);
|
||||
this.source_ = new ObservedPropertyObjectPU<C>(source as C, this, this.getSourceObservedPropertyFakeName());
|
||||
this.sourceIsOwnObject = true;
|
||||
}
|
||||
|
||||
if (this.source_ != undefined) {
|
||||
@ -106,6 +108,7 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor ready with local copy.`);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
like a destructor, need to call this before deleting
|
||||
the property.
|
||||
@ -128,18 +131,25 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
}
|
||||
|
||||
public syncPeerHasChanged(eventSource: ObservedPropertyAbstractPU<C>) {
|
||||
|
||||
if (this.source_ == undefined) {
|
||||
stateMgmtConsole.error(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: \
|
||||
@Prop syncPeerHasChanged peer '${eventSource ? eventSource.info() : "no eventSource info"}' but source_ undefned. Internal error.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventSource && this.source_ == eventSource) {
|
||||
// defensive programming: should always be the case!
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectOneWayPU[${this.id__()}]: syncPeerHasChanged(): Source '${eventSource.info()}' has changed'.`)
|
||||
const newValue = this.source_.getUnmonitored();
|
||||
if (typeof newValue == "object") {
|
||||
if (this.checkIsSupportedValue(newValue)) {
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: hasChanged: newValue '${JSON.stringify(newValue)}'.`);
|
||||
if (this.resetLocalValue(newValue, /* needCopyObject */ true)) {
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stateMgmtConsole.warn(`SynchedPropertyObjectOneWayPU[${this.id__()}]: syncPeerHasChanged Unexpected situation. Ignoring event.`)
|
||||
stateMgmtConsole.warn(`SynchedPropertyObjectOneWayPU[${this.id__()}]: syncPeerHasChanged Unexpected situation. syncPeerHasChanged from different sender than source_. Ignoring event.`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,11 +190,6 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
}
|
||||
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: set to newV value.`);
|
||||
if (!ObservedObject.IsObservedObject(newValue)) {
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Set: Provided new object's class
|
||||
lacks '@Observed' class decorator. Object property changes will not be observed.`);
|
||||
}
|
||||
|
||||
if (this.resetLocalValue(newValue, /* needCopyObject */ false)) {
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
@ -193,11 +198,9 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
// called when updated from parent
|
||||
public reset(sourceChangedValue: C): void {
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: reset.`);
|
||||
if (this.source_ !== undefined) {
|
||||
if (this.source_ !== undefined && this.checkIsSupportedValue(sourceChangedValue)) {
|
||||
// if this.source_.set causes an actual change, then, ObservedPropertyObject source_ will call syncPeerHasChanged method
|
||||
this.source_.set(sourceChangedValue);
|
||||
} else {
|
||||
stateMgmtConsole.error(`SynchedPropertyObjectOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: reset @Prop --- No source_. Internal error!`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,11 +215,9 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
// note: We can not test for newObservedObjectValue == this.localCopyObservedObject_
|
||||
// here because the object might still be the same, but some property of it has changed
|
||||
|
||||
if (typeof newObservedObjectValue !== "object") {
|
||||
// if not undefined or null, then the provided newObservedObjectValue must be an Object
|
||||
stateMgmtConsole.error(`SynchedPropertyOneWayObjectPU[${this.id__()}]: setLocalValue new value must be an Object.`)
|
||||
if(!this.checkIsSupportedValue(newObservedObjectValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// unsubscribe from old local copy
|
||||
if (this.localCopyObservedObject_ instanceof SubscribableAbstract) {
|
||||
(this.localCopyObservedObject_ as SubscribableAbstract).removeOwningProperty(this);
|
||||
@ -227,23 +228,23 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
// shallow/deep copy value
|
||||
// needed whenever newObservedObjectValue comes from source
|
||||
// not needed on a local set (aka when called from set() method)
|
||||
let copy = needCopyObject ? this.copyObject(newObservedObjectValue, this.info_) : newObservedObjectValue;
|
||||
this.localCopyObservedObject_ = needCopyObject ? this.copyObject(newObservedObjectValue, this.info_) : newObservedObjectValue;
|
||||
|
||||
if (copy instanceof SubscribableAbstract) {
|
||||
this.localCopyObservedObject_ = copy;
|
||||
// deep copy will copy Set of subscribers as well. But local copy only has its own subscribers
|
||||
// not those of its parent value.
|
||||
(this.localCopyObservedObject_ as unknown as SubscribableAbstract).clearOwningProperties();
|
||||
(this.localCopyObservedObject_ as unknown as SubscribableAbstract).addOwningProperty(this);
|
||||
} else if (ObservedObject.IsObservedObject(copy)) {
|
||||
// case: new ObservedObject
|
||||
this.localCopyObservedObject_ = copy;
|
||||
ObservedObject.addOwningProperty(this.localCopyObservedObject_, this);
|
||||
} else {
|
||||
// wrap newObservedObjectValue raw object as ObservedObject and subscribe to it
|
||||
stateMgmtConsole.warn(`@Prop ${this.info()} Provided source object's class \
|
||||
if (typeof this.localCopyObservedObject_ == "object") {
|
||||
if (this.localCopyObservedObject_ instanceof SubscribableAbstract) {
|
||||
// deep copy will copy Set of subscribers as well. But local copy only has its own subscribers
|
||||
// not those of its parent value.
|
||||
(this.localCopyObservedObject_ as unknown as SubscribableAbstract).clearOwningProperties();
|
||||
(this.localCopyObservedObject_ as unknown as SubscribableAbstract).addOwningProperty(this);
|
||||
} else if (ObservedObject.IsObservedObject(this.localCopyObservedObject_)) {
|
||||
// case: new ObservedObject
|
||||
ObservedObject.addOwningProperty(this.localCopyObservedObject_, this);
|
||||
} else {
|
||||
// wrap newObservedObjectValue raw object as ObservedObject and subscribe to it
|
||||
stateMgmtConsole.error(`@Prop ${this.info()} Provided source object's class \
|
||||
lacks @Observed class decorator. Object property changes will not be observed.`);
|
||||
this.localCopyObservedObject_ = ObservedObject.createNew(copy, this);
|
||||
this.localCopyObservedObject_ = ObservedObject.createNew(this.localCopyObservedObject_, this);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -263,14 +264,14 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
}
|
||||
|
||||
// API 9 code path
|
||||
private shallowCopyObject(value: C, propName: string) : C {
|
||||
private shallowCopyObject(value: C, propName: string): C {
|
||||
let rawValue = ObservedObject.GetRawObject(value);
|
||||
let copy: C;
|
||||
|
||||
if (rawValue == undefined || rawValue == null) {
|
||||
if (!rawValue || typeof rawValue !== 'object') {
|
||||
copy = rawValue;
|
||||
} else if (typeof rawValue != "object") {
|
||||
// TODO would it be better to crash the app here?
|
||||
// FIXME would it be better to throw Exception here?
|
||||
stateMgmtConsole.error(`@Prop ${this.info()} shallowCopyObject: request to copy non-object but defined value of type '${typeof rawValue}'. Internal error! Setting copy=original value.`);
|
||||
copy = rawValue;
|
||||
} else if (rawValue instanceof Array) {
|
||||
@ -379,3 +380,12 @@ class SynchedPropertyObjectOneWayPU<C extends Object>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// class definitions for backward compatibility
|
||||
class SynchedPropertySimpleOneWayPU<T> extends SynchedPropertyOneWayPU<T> {
|
||||
|
||||
}
|
||||
|
||||
class SynchedPropertyObjectOneWayPU<T> extends SynchedPropertyOneWayPU<T> {
|
||||
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* SynchedPropertySimpleOneWayPU
|
||||
* implementation of @Prop decorated variable of types boolean | number | string | enum
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
|
||||
class SynchedPropertySimpleOneWayPU<T> extends ObservedPropertySimpleAbstractPU<T>
|
||||
implements PeerChangeEventReceiverPU<T> {
|
||||
|
||||
private wrappedValue_: T;
|
||||
private source_: ObservedPropertyAbstract<T>;
|
||||
|
||||
// true for @Prop code path,
|
||||
// false for @(Local)StorageProp
|
||||
private sourceIsOwnObject: boolean;
|
||||
|
||||
constructor(source: ObservedPropertyAbstract<T> | T, subscribeMe?: IPropertySubscriber, thisPropertyName?: PropertyInfo) {
|
||||
super(subscribeMe, thisPropertyName);
|
||||
|
||||
// Check that source is ObservedPropertyAbstruct
|
||||
if (source && (typeof (source) === "object") && ("notifyHasChanged" in source) && ("subscribeMe" in source)) {
|
||||
// code path for @(Local)StorageProp
|
||||
this.source_ = source;
|
||||
this.sourceIsOwnObject = false;
|
||||
this.source_.addSubscriber(this);
|
||||
// subscribe to receive value change updates from LocalStorage source property
|
||||
} else {
|
||||
// code path for @Prop
|
||||
this.source_ = new ObservedPropertySimplePU<T>(source as T, this, thisPropertyName);
|
||||
this.sourceIsOwnObject = true;
|
||||
}
|
||||
|
||||
// use own backing store for value to avoid
|
||||
// value changes to be propagated back to source
|
||||
this.wrappedValue_ = this.source_.getUnmonitored();
|
||||
}
|
||||
|
||||
/*
|
||||
like a destructor, need to call this before deleting
|
||||
the property.
|
||||
*/
|
||||
aboutToBeDeleted() {
|
||||
if (this.source_) {
|
||||
this.source_.removeSubscriber(this);
|
||||
if (this.sourceIsOwnObject == true && this.source_.numberOfSubscrbers()==0){
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: aboutToBeDeleted. owning source_ ObservedPropertySimplePU, calling its aboutToBeDeleted`);
|
||||
this.source_.aboutToBeDeleted();
|
||||
}
|
||||
this.source_ = undefined;
|
||||
this.sourceIsOwnObject= false;
|
||||
}
|
||||
super.aboutToBeDeleted();
|
||||
}
|
||||
|
||||
public syncPeerHasChanged(eventSource: ObservedPropertyAbstractPU<T>) {
|
||||
if (eventSource && (eventSource == this.source_)) {
|
||||
// defensive, should always be the case
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: \
|
||||
syncPeerHasChanged peer '${eventSource.info()}'.`);
|
||||
this.setWrappedValue(eventSource.getUnmonitored());
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
|
||||
public getUnmonitored(): T {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: getUnmonitored.`);
|
||||
// unmonitored get access, no call to notifyPropertyRead !
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
|
||||
// get 'read through` from the ObservedProperty
|
||||
public get(): T {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: get returns '${this.wrappedValue_}'`);
|
||||
this.notifyPropertyHasBeenReadPU()
|
||||
return this.wrappedValue_;
|
||||
}
|
||||
|
||||
public set(newValue: T): void {
|
||||
if (this.wrappedValue_ == newValue) {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: set with unchanged value '${this.wrappedValue_}'- ignoring.`);
|
||||
return;
|
||||
}
|
||||
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: set from '${this.wrappedValue_} to '${newValue}'.`);
|
||||
this.setWrappedValue(newValue);
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
|
||||
public reset(sourceChangedValue: T): void {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleOneWayPU[${this.id__()}, '${this.info() || "unknown"}']: reset from '${this.wrappedValue_} to '${sourceChangedValue}'.`);
|
||||
// if set causes an actual change, then, ObservedPropertySimple source_ will call hasChanged
|
||||
if (this.source_ !== undefined) {
|
||||
// if set causes an actual change, then, ObservedPropertySimple source_ will call hasChanged
|
||||
this.source_.set(sourceChangedValue);
|
||||
}
|
||||
}
|
||||
|
||||
private setWrappedValue(newValue: T): void {
|
||||
this.wrappedValue_ = newValue;
|
||||
}
|
||||
}
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SynchedPropertySimpleTwoWayPU
|
||||
* implementation of @Link and @Consume decorated variables of types boolean | number | string | enum
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
|
||||
class SynchedPropertySimpleTwoWayPU<T> extends ObservedPropertySimpleAbstractPU<T>
|
||||
implements PeerChangeEventReceiverPU<T> {
|
||||
|
||||
private source_: ObservedPropertyAbstract<T>;
|
||||
private changeNotificationIsOngoing_: boolean = false;
|
||||
|
||||
constructor(source: ObservedPropertyAbstract<T>, owningView: IPropertySubscriber, owningViewPropNme: PropertyInfo) {
|
||||
super(owningView, owningViewPropNme);
|
||||
this.source_ = source;
|
||||
if (this.source_) {
|
||||
this.source_.addSubscriber(this);
|
||||
} else {
|
||||
stateMgmtConsole.error(`SynchedPropertySimpleTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Link/@Consume source must not be undefined. Application error!`);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
like a destructor, need to call this before deleting
|
||||
the property.
|
||||
*/
|
||||
aboutToBeDeleted() {
|
||||
if (this.source_) {
|
||||
this.source_.removeSubscriber(this);
|
||||
this.source_ = undefined;
|
||||
}
|
||||
super.aboutToBeDeleted();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when sync peer ObservedPropertySimple or SynchedPropertySimpletTwoWay has chnaged value
|
||||
* that peer can be in either parent or child component if 'this' is used for a @Link
|
||||
* that peer can be in either acestor or descendant component if 'this' is used for a @Consume
|
||||
* @param eventSource
|
||||
*/
|
||||
syncPeerHasChanged(eventSource : ObservedPropertyAbstractPU<T>) {
|
||||
if (!this.changeNotificationIsOngoing_) {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: propertyHasChangedPU, property ${eventSource.info()}`);
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
}
|
||||
|
||||
public getUnmonitored(): T {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: getUnmonitored`);
|
||||
return (this.source_ ? this.source_.getUnmonitored() : undefined);
|
||||
}
|
||||
|
||||
// get 'read through` from the ObservedProperty
|
||||
public get(): T {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: get`);
|
||||
this.notifyPropertyHasBeenReadPU()
|
||||
return this.getUnmonitored();
|
||||
}
|
||||
|
||||
// set 'writes through` to the ObservedProperty
|
||||
public set(newValue: T): void {
|
||||
if (!this.source_) {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleTwoWayPU[${this.id__()}IP, '${this.info() || "unknown"}']: set, no source, returning.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.source_.get() == newValue) {
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleTwoWayPU[${this.id__()}IP, '${this.info() || "unknown"}']: set with unchanged value '${newValue}'- ignoring.`);
|
||||
return;
|
||||
}
|
||||
|
||||
stateMgmtConsole.debug(`SynchedPropertySimpleTwoWayPU[${this.id__()}IP, '${this.info() || "unknown"}']: set to newValue: '${newValue}'.`);
|
||||
|
||||
// avoid circular notifications @Link -> source @State -> other but also to same @Link
|
||||
this.changeNotificationIsOngoing_ = true;
|
||||
|
||||
// the source_ ObservedProeprty will call: this.hasChanged(newValue);
|
||||
this.source_.set(newValue);
|
||||
this.notifyPropertyHasChangedPU();
|
||||
|
||||
this.changeNotificationIsOngoing_ = false;
|
||||
}
|
||||
}
|
@ -18,11 +18,10 @@
|
||||
* implementation of @Link and @Consume decorated variables of type class object
|
||||
*
|
||||
* all definitions in this file are framework internal
|
||||
*/
|
||||
class SynchedPropertyObjectTwoWayPU<C extends Object>
|
||||
extends ObservedPropertyObjectAbstractPU<C>
|
||||
implements PeerChangeEventReceiverPU<C>,
|
||||
ObservedObjectEventsPUReceiver<C> {
|
||||
*/
|
||||
|
||||
class SynchedPropertyTwoWayPU<C> extends ObservedPropertyAbstractPU<C>
|
||||
implements PeerChangeEventReceiverPU<C>, ObservedObjectEventsPUReceiver<C> {
|
||||
|
||||
private source_: ObservedPropertyObjectAbstract<C>;
|
||||
private changeNotificationIsOngoing_: boolean = false;
|
||||
@ -38,7 +37,7 @@ class SynchedPropertyObjectTwoWayPU<C extends Object>
|
||||
// register to the ObservedObject
|
||||
ObservedObject.addOwningProperty(this.source_.get(), this);
|
||||
} else {
|
||||
stateMgmtConsole.error(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Link/@Consume source must not be undefined. Application error!`);
|
||||
throw new SyntaxError(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: constructor @Link/@Consume source variable in parent/ancestor @ Component must be defined. Application error!`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,25 +62,31 @@ class SynchedPropertyObjectTwoWayPU<C extends Object>
|
||||
|
||||
private setObject(newValue: C): void {
|
||||
if (!this.source_) {
|
||||
stateMgmtConsole.warn(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: setObject (assign a new value), @Link/@Consume: no linked parent property. Likely a consequence of earlier application error.`);
|
||||
return;
|
||||
throw new SyntaxError(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: setObject (assign a new value), \
|
||||
@Link/@Consume: no source variable in parent/ancestor @Component. Application error.`);
|
||||
}
|
||||
|
||||
let oldValueObject = this.getUnmonitored();
|
||||
if (oldValueObject != undefined && oldValueObject != null) {
|
||||
ObservedObject.removeOwningProperty(oldValueObject, this);
|
||||
if (this.getUnmonitored() == newValue) {
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectTwoWayPU[${this.id__()}IP, '${this.info() || "unknown"}']: set with unchanged value - ignoring.`);
|
||||
return;
|
||||
}
|
||||
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectTwoWayPU[${this.id__()}IP, '${this.info() || "unknown"}']: set.`);
|
||||
|
||||
if (this.checkIsSupportedValue(newValue)) {
|
||||
// the source_ ObservedProperty will call: this.syncPeerHasChanged(newValue);
|
||||
this.source_.set(newValue)
|
||||
ObservedObject.addOwningProperty(this.getUnmonitored(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when sync peer ObservedPropertyObject or SynchedPropertyObjectTwoWay has chnaged value
|
||||
* Called when sync peer ObservedPropertyObject or SynchedPropertyObjectTwoWay has changed value
|
||||
* that peer can be in either parent or child component if 'this' is used for a @Link
|
||||
* that peer can be in either acestor or descendant component if 'this' is used for a @Consume
|
||||
* that peer can be in either ancestor or descendant component if 'this' is used for a @Consume
|
||||
* @param eventSource
|
||||
*/
|
||||
syncPeerHasChanged(eventSource : ObservedPropertyAbstractPU<C>) {
|
||||
syncPeerHasChanged(eventSource: ObservedPropertyAbstractPU<C>) {
|
||||
if (!this.changeNotificationIsOngoing_) {
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: propertyHasChangedPU: contained ObservedObject '${eventSource.info()}' hasChanged'.`)
|
||||
this.notifyPropertyHasChangedPU();
|
||||
@ -93,13 +98,13 @@ class SynchedPropertyObjectTwoWayPU<C extends Object>
|
||||
* @param souceObject
|
||||
* @param changedPropertyName
|
||||
*/
|
||||
public objectPropertyHasChangedPU(souceObject: ObservedObject<C>, changedPropertyName : string) {
|
||||
public objectPropertyHasChangedPU(sourceObject: ObservedObject<C>, changedPropertyName : string) {
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: \
|
||||
objectPropertyHasChangedPU: contained ObservedObject property '${changedPropertyName}' has changed.`)
|
||||
this.notifyPropertyHasChangedPU();
|
||||
}
|
||||
|
||||
public objectPropertyHasBeenReadPU(souceObject: ObservedObject<C>, changedPropertyName : string) {
|
||||
public objectPropertyHasBeenReadPU(sourceObject: ObservedObject<C>, changedPropertyName : string) {
|
||||
stateMgmtConsole.debug(`SynchedPropertyObjectTwoWayPU[${this.id__()}, '${this.info() || "unknown"}']: \
|
||||
objectPropertyHasBeenReadPU: contained ObservedObject property '${changedPropertyName}' has been read.`);
|
||||
this.notifyPropertyHasBeenReadPU();
|
||||
@ -134,3 +139,13 @@ class SynchedPropertyObjectTwoWayPU<C extends Object>
|
||||
this.changeNotificationIsOngoing_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
// class definitions for backward compatibility
|
||||
class SynchedPropertyObjectTwoWayPU<C> extends SynchedPropertyTwoWayPU<C> {
|
||||
|
||||
}
|
||||
|
||||
class SynchedPropertySimpleTwoWayPU<T> extends SynchedPropertyTwoWayPU<T> {
|
||||
|
||||
}
|
||||
|
@ -500,31 +500,35 @@ abstract class ViewPU extends NativeViewPartialUpdate
|
||||
/**
|
||||
* Method for the sub-class to call from its constructor for resolving
|
||||
* a @Consume variable and initializing its backing store
|
||||
* with the yncedPropertyTwoWay<T> object created from the
|
||||
* with the SyncedPropertyTwoWay<T> object created from the
|
||||
* @Provide variable's backing store.
|
||||
* @param providedPropName the name of the @Provide'd variable.
|
||||
* This is either the @Consume decortor parameter, or variable name.
|
||||
* This is either the @Consume decorator parameter, or variable name.
|
||||
* @param consumeVarName the @Consume variable name (not the
|
||||
* @Consume decortor parameter)
|
||||
* @returns initiaizing value of the @Consume backing store
|
||||
* @Consume decorator parameter)
|
||||
* @returns initializing value of the @Consume backing store
|
||||
*/
|
||||
protected initializeConsume<T>(providedPropName: string,
|
||||
consumeVarName: string): ObservedPropertyAbstractPU<T> {
|
||||
let providedVarStore = this.providedVars_.get(providedPropName);
|
||||
let providedVarStore : ObservedPropertyAbstractPU<any> = this.providedVars_.get(providedPropName);
|
||||
if (providedVarStore === undefined) {
|
||||
throw new ReferenceError(`${this.constructor.name}: missing @Provide property with name ${providedPropName}.
|
||||
Fail to resolve @Consume(${providedPropName}).`);
|
||||
Fail to resolve @Consume(${providedPropName}).`);
|
||||
}
|
||||
|
||||
return providedVarStore.createSync(
|
||||
<T>(source: ObservedPropertyAbstract<T>) => (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleTwoWayPU<T>(source, this, consumeVarName)
|
||||
: new SynchedPropertyObjectTwoWayPU<T>(source, this, consumeVarName)) as ObservedPropertyAbstractPU<T>;
|
||||
const factory = <T>(source: ObservedPropertyAbstract<T>) => {
|
||||
const result : ObservedPropertyAbstractPU<T> = ((source instanceof ObservedPropertySimple) || (source instanceof ObservedPropertySimplePU))
|
||||
? new SynchedPropertyObjectTwoWayPU<T>(source, this, consumeVarName)
|
||||
: new SynchedPropertyObjectTwoWayPU<T>(source, this, consumeVarName);
|
||||
stateMgmtConsole.error(`The @Consume is instance of ${result.constructor.name}`);
|
||||
return result;
|
||||
};
|
||||
return providedVarStore.createSync(factory) as ObservedPropertyAbstractPU<T>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* given the elmtid of a child or child of child within this custom component
|
||||
* given the elmtId of a child or child of child within this custom component
|
||||
* remember this component needs a partial update
|
||||
* @param elmtId
|
||||
*/
|
||||
@ -793,7 +797,7 @@ abstract class ViewPU extends NativeViewPartialUpdate
|
||||
<T>(source: ObservedPropertyAbstract<T>) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleTwoWayPU<T>(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectTwoWayPU<T>(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectTwoWayPU<T>(source, this, viewVariableName)
|
||||
) as ObservedPropertyAbstractPU<T>;
|
||||
this.ownStorageLinksProps_.add(appStorageLink);
|
||||
@ -805,7 +809,7 @@ abstract class ViewPU extends NativeViewPartialUpdate
|
||||
<T>(source: ObservedPropertyAbstract<T>) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleOneWayPU<T>(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectOneWayPU<T>(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectOneWayPU<T>(source, this, viewVariableName)
|
||||
) as ObservedPropertyAbstractPU<T>;
|
||||
this.ownStorageLinksProps_.add(appStorageProp);
|
||||
@ -818,7 +822,7 @@ abstract class ViewPU extends NativeViewPartialUpdate
|
||||
<T>(source: ObservedPropertyAbstract<T>) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleTwoWayPU<T>(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectTwoWayPU<T>(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectTwoWayPU<T>(source, this, viewVariableName)
|
||||
) as ObservedPropertyAbstractPU<T>;
|
||||
this.ownStorageLinksProps_.add(localStorageLink);
|
||||
@ -831,7 +835,7 @@ abstract class ViewPU extends NativeViewPartialUpdate
|
||||
<T>(source: ObservedPropertyAbstract<T>) => (source === undefined)
|
||||
? undefined
|
||||
: (source instanceof ObservedPropertySimple)
|
||||
? new SynchedPropertySimpleOneWayPU<T>(source, this, viewVariableName)
|
||||
? new SynchedPropertyObjectOneWayPU<T>(source, this, viewVariableName)
|
||||
: new SynchedPropertyObjectOneWayPU<T>(source, this, viewVariableName)
|
||||
) as ObservedPropertyAbstractPU<T>;
|
||||
this.ownStorageLinksProps_.add(localStorageProp);
|
||||
|
@ -50,14 +50,9 @@
|
||||
"src/lib/partial_update/pu_foreach.d.ts",
|
||||
"src/lib/partial_update/pu_view_native.d.ts",
|
||||
"src/lib/partial_update/pu_observed_property_abstract.ts",
|
||||
"src/lib/partial_update/pu_observed_property_object_abstract.ts",
|
||||
"src/lib/partial_update/pu_observed_property_simple_abstract.ts",
|
||||
"src/lib/partial_update/pu_observed_property_object.ts",
|
||||
"src/lib/partial_update/pu_observed_property_simple.ts",
|
||||
"src/lib/partial_update/pu_synced_property_object_one_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_object_two_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_simple_one_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_simple_two_way.ts",
|
||||
"src/lib/partial_update/pu_observed_property.ts",
|
||||
"src/lib/partial_update/pu_synced_property_one_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_two_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_object_nested.ts",
|
||||
"src/lib/partial_update/pu_view.ts",
|
||||
"src/lib/partial_update/pu_recycle_manager.ts",
|
||||
|
@ -50,14 +50,9 @@
|
||||
"src/lib/partial_update/pu_foreach.d.ts",
|
||||
"src/lib/partial_update/pu_view_native.d.ts",
|
||||
"src/lib/partial_update/pu_observed_property_abstract.ts",
|
||||
"src/lib/partial_update/pu_observed_property_object_abstract.ts",
|
||||
"src/lib/partial_update/pu_observed_property_simple_abstract.ts",
|
||||
"src/lib/partial_update/pu_observed_property_object.ts",
|
||||
"src/lib/partial_update/pu_observed_property_simple.ts",
|
||||
"src/lib/partial_update/pu_synced_property_object_one_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_object_two_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_simple_one_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_simple_two_way.ts",
|
||||
"src/lib/partial_update/pu_observed_property.ts",
|
||||
"src/lib/partial_update/pu_synced_property_one_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_two_way.ts",
|
||||
"src/lib/partial_update/pu_synced_property_object_nested.ts",
|
||||
"src/lib/partial_update/pu_view.ts",
|
||||
"src/lib/partial_update/pu_recycle_manager.ts",
|
||||
|
@ -38,14 +38,9 @@
|
||||
"src/lib/common/observed_property_abstract.ts",
|
||||
|
||||
// full_update specific
|
||||
"src/lib/full_update/fu_observed_property_object_abstract.ts",
|
||||
"src/lib/full_update/fu_observed_property_simple_abstract.ts",
|
||||
"src/lib/full_update/fu_observed_property_object.ts",
|
||||
"src/lib/full_update/fu_observed_property_simple.ts",
|
||||
"src/lib/full_update/fu_synced_property_object_two_way.ts",
|
||||
"src/lib/full_update/fu_synced_property_simple_one_way.ts",
|
||||
"src/lib/full_update/fu_synced_property_simple_two_way.ts",
|
||||
"src/lib/full_update/fu_synced_property_object_nested.ts",
|
||||
"src/lib/full_update/fu_observed_property.ts",
|
||||
"src/lib/full_update/fu_synced_property_two_way.ts",
|
||||
"src/lib/full_update/fu_synced_property_one_way.ts",
|
||||
"src/lib/full_update/fu_view.ts",
|
||||
|
||||
// partial update specific
|
||||
|
@ -235,6 +235,19 @@ RefPtr<Frontend> Frontend::Create()
|
||||
return AceType::MakeRefPtr<JsFrontend>();
|
||||
}
|
||||
|
||||
bool Frontend::MaybeRelease()
|
||||
{
|
||||
CHECK_RUN_ON(JS);
|
||||
CHECK_NULL_RETURN(taskExecutor_, true);
|
||||
if (taskExecutor_->WillRunOnCurrentThread(TaskExecutor::TaskType::JS)) {
|
||||
LOGI("Destroy Frontend on JS thread.");
|
||||
return true;
|
||||
} else {
|
||||
LOGI("Post Destroy Frontend Task to JS thread.");
|
||||
return !taskExecutor_->PostTask([this] { delete this; }, TaskExecutor::TaskType::JS);
|
||||
}
|
||||
}
|
||||
|
||||
JsFrontend::~JsFrontend() noexcept
|
||||
{
|
||||
LOG_DESTROY();
|
||||
@ -255,6 +268,7 @@ bool JsFrontend::Initialize(FrontendType type, const RefPtr<TaskExecutor>& taskE
|
||||
{
|
||||
LOGI("JsFrontend initialize begin.");
|
||||
type_ = type;
|
||||
taskExecutor_ = taskExecutor;
|
||||
ACE_DCHECK(type_ == FrontendType::JS);
|
||||
InitializeFrontendDelegate(taskExecutor);
|
||||
auto weakEngine = AceType::WeakClaim(AceType::RawPtr(jsEngine_));
|
||||
|
@ -60,12 +60,12 @@ public:
|
||||
void PushPage(const std::string& url, const std::string& params) override;
|
||||
|
||||
// Js frontend manages all pages self.
|
||||
void AddPage(const RefPtr<AcePage>& page) override {};
|
||||
void AddPage(const RefPtr<AcePage>& page) override {}
|
||||
|
||||
RefPtr<AcePage> GetPage(int32_t pageId) const override
|
||||
{
|
||||
return delegate_->GetPage(pageId);
|
||||
};
|
||||
}
|
||||
|
||||
WeakPtr<AcePage> GetCurrentReadyPage() const
|
||||
{
|
||||
@ -130,11 +130,6 @@ public:
|
||||
RefPtr<AceEventHandler> GetEventHandler() override
|
||||
{
|
||||
return handler_;
|
||||
};
|
||||
|
||||
FrontendType GetType() override
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
// judge frontend is foreground frontend.
|
||||
@ -179,7 +174,6 @@ public:
|
||||
private:
|
||||
void InitializeFrontendDelegate(const RefPtr<TaskExecutor>& taskExecutor);
|
||||
|
||||
FrontendType type_ = FrontendType::JS;
|
||||
RefPtr<Framework::FrontendDelegateImpl> delegate_;
|
||||
RefPtr<AceEventHandler> handler_;
|
||||
RefPtr<Framework::JsEngine> jsEngine_;
|
||||
|
@ -176,6 +176,7 @@ void PluginFrontend::Destroy()
|
||||
bool PluginFrontend::Initialize(FrontendType type, const RefPtr<TaskExecutor>& taskExecutor)
|
||||
{
|
||||
type_ = type;
|
||||
taskExecutor_ = taskExecutor;
|
||||
ACE_DCHECK(type_ == FrontendType::JS_PLUGIN);
|
||||
InitializeFrontendDelegate(taskExecutor);
|
||||
taskExecutor->PostSyncTask(
|
||||
|
@ -60,12 +60,12 @@ public:
|
||||
void PushPage(const std::string& url, const std::string& params) override;
|
||||
|
||||
// Js frontend manages all pages self.
|
||||
void AddPage(const RefPtr<AcePage>& page) override {};
|
||||
void AddPage(const RefPtr<AcePage>& page) override {}
|
||||
|
||||
RefPtr<AcePage> GetPage(int32_t pageId) const override
|
||||
{
|
||||
return nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
void TriggerGarbageCollection() override;
|
||||
|
||||
@ -119,11 +119,6 @@ public:
|
||||
RefPtr<AceEventHandler> GetEventHandler() override
|
||||
{
|
||||
return handler_;
|
||||
};
|
||||
|
||||
FrontendType GetType() override
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
// judge frontend is foreground frontend.
|
||||
@ -216,7 +211,6 @@ public:
|
||||
private:
|
||||
void InitializeFrontendDelegate(const RefPtr<TaskExecutor>& taskExecutor);
|
||||
|
||||
FrontendType type_ = FrontendType::DECLARATIVE_JS;
|
||||
RefPtr<Framework::PluginFrontendDelegate> delegate_;
|
||||
RefPtr<AceEventHandler> handler_;
|
||||
RefPtr<Framework::JsEngine> jsEngine_;
|
||||
|
@ -30,13 +30,13 @@ public:
|
||||
~MockPlatformWindow() override = default;
|
||||
|
||||
// Request next vsync.
|
||||
void RequestFrame() override {};
|
||||
void RequestFrame() override {}
|
||||
|
||||
// Register Vsync callback.
|
||||
void RegisterVsyncCallback(AceVsyncCallback&& callback) override {};
|
||||
void RegisterVsyncCallback(AceVsyncCallback&& callback) override {}
|
||||
|
||||
// Attach root render node to container
|
||||
void SetRootRenderNode(const RefPtr<RenderNode>& root) override {};
|
||||
void SetRootRenderNode(const RefPtr<RenderNode>& root) override {}
|
||||
};
|
||||
|
||||
class MockFrontend : public Frontend {
|
||||
@ -66,11 +66,6 @@ public:
|
||||
return windowConfig_;
|
||||
}
|
||||
|
||||
FrontendType GetType() override
|
||||
{
|
||||
return FrontendType::JS;
|
||||
}
|
||||
|
||||
bool OnBackPressed() override
|
||||
{
|
||||
return false;
|
||||
|
@ -286,7 +286,7 @@ bool SvgAnimate::CreateLinearAnimate(
|
||||
animation->AddListener(std::move(callback));
|
||||
animator->AddInterpolator(animation);
|
||||
} else {
|
||||
if (!LinearAnimate(std::move(callback), originalValue, animator)) {
|
||||
if (!LinearAnimateFromTo(std::move(callback), originalValue, animator)) {
|
||||
LOGW("create linear animate failed");
|
||||
return false;
|
||||
}
|
||||
@ -300,7 +300,7 @@ bool SvgAnimate::CreateLinearAnimate(
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool SvgAnimate::LinearAnimate(
|
||||
bool SvgAnimate::LinearAnimateFromTo(
|
||||
std::function<void(T)>&& callback, const T& originalValue, const RefPtr<Animator>& animator)
|
||||
{
|
||||
if (!animator) {
|
||||
@ -416,7 +416,7 @@ bool SvgAnimate::CreatePacedAnimate(
|
||||
animation->AddListener(std::move(callback));
|
||||
animator->AddInterpolator(animation);
|
||||
} else {
|
||||
if (!LinearAnimate(std::move(callback), originalValue, animator)) {
|
||||
if (!LinearAnimateFromTo(std::move(callback), originalValue, animator)) {
|
||||
LOGW("create linear animate failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -453,7 +453,8 @@ private:
|
||||
bool CreateLinearAnimate(
|
||||
std::function<void(T)>&& callback, const T& originalValue, const RefPtr<Animator>& animator);
|
||||
template<typename T>
|
||||
bool LinearAnimate(std::function<void(T)>&& callback, const T& originalValue, const RefPtr<Animator>& animator);
|
||||
bool LinearAnimateFromTo(
|
||||
std::function<void(T)>&& callback, const T& originalValue, const RefPtr<Animator>& animator);
|
||||
template<typename T>
|
||||
bool LinearAnimate(const RefPtr<KeyframeAnimation<T>>& animation);
|
||||
template<typename T>
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_UI_EXTENSION_HELPER_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_UI_EXTENSION_HELPER_H
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_APP_BAR_HELPER_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_APP_BAR_HELPER_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@ -23,13 +23,15 @@
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
class ACE_EXPORT UIExtensionHelper final {
|
||||
class ACE_EXPORT AppBarHelper final {
|
||||
public:
|
||||
static RefPtr<NG::FrameNode> CreateUIExtensionNode(const std::string& bundleName,
|
||||
const std::string& abilityName, const std::map<std::string, std::string>& params,
|
||||
std::function<void(int32_t)>&& onRelease,
|
||||
std::function<void(int32_t, const std::string&, const std::string&)>&& onError);
|
||||
|
||||
static std::string QueryAppGalleryBundleName();
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_UI_EXTENSION_HELPER_H
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_APP_BAR_HELPER_H
|
@ -110,7 +110,7 @@ public:
|
||||
|
||||
// Get the stage mode sourceMap.
|
||||
virtual void GetStageSourceMap(
|
||||
std::unordered_map<std::string, RefPtr<Framework::RevSourceMap>>& sourceMap) const {};
|
||||
std::unordered_map<std::string, RefPtr<Framework::RevSourceMap>>& sourceMap) const {}
|
||||
|
||||
virtual void RunPage(int32_t pageId, const std::string& content, const std::string& params) = 0;
|
||||
|
||||
@ -124,7 +124,15 @@ public:
|
||||
// Get window config of front end, which is used to calculate the pixel ratio of the real device.
|
||||
virtual WindowConfig& GetWindowConfig() = 0;
|
||||
|
||||
virtual FrontendType GetType() = 0;
|
||||
FrontendType GetType() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
RefPtr<TaskExecutor> GetTaskExecutor() const
|
||||
{
|
||||
return taskExecutor_;
|
||||
}
|
||||
|
||||
// inform the frontend that onCreate or onDestroy
|
||||
virtual void UpdateState(State) = 0;
|
||||
@ -268,7 +276,7 @@ public:
|
||||
|
||||
virtual void FlushReload() {}
|
||||
// flush frontend for HotReload feature in NG
|
||||
virtual void HotReload() {};
|
||||
virtual void HotReload() {}
|
||||
|
||||
State GetState() const
|
||||
{
|
||||
@ -278,6 +286,9 @@ public:
|
||||
virtual void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback) {}
|
||||
|
||||
protected:
|
||||
virtual bool MaybeRelease() override;
|
||||
FrontendType type_ = FrontendType::JS;
|
||||
RefPtr<TaskExecutor> taskExecutor_;
|
||||
bool disallowPopLastPage_ = false;
|
||||
FrontendDialogCallback dialogCallback_ = nullptr;
|
||||
State state_ = State::UNDEFINE;
|
||||
|
@ -49,8 +49,8 @@ public:
|
||||
const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) = 0;
|
||||
virtual void AddPixelMapRecord(const RefPtr<UnifiedData>& unifiedData, std::vector<uint8_t>& data) = 0;
|
||||
virtual void AddImageRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& uri) = 0;
|
||||
virtual void AddTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr) = 0;
|
||||
virtual std::string GetSingleTextRecord(const RefPtr<UnifiedData>& unifiedData) = 0;
|
||||
virtual void AddPlainTextRecord(const RefPtr<UnifiedData>& unifiedData, const std::string& selectedStr) = 0;
|
||||
virtual std::string GetSinglePlainTextRecord(const RefPtr<UnifiedData>& unifiedData) = 0;
|
||||
virtual int32_t GetVideoRecordUri(const RefPtr<UnifiedData>& unifiedData, std::string& uri) = 0;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -363,6 +363,7 @@ enum class WindowType : uint32_t {
|
||||
WINDOW_TYPE_UNDEFINED = 0,
|
||||
WINDOW_TYPE_APP_BASE = 1,
|
||||
WINDOW_TYPE_APP_END = 1003,
|
||||
WINDOW_TYPE_FLOAT = 2106,
|
||||
};
|
||||
|
||||
enum class PanelType {
|
||||
|
@ -135,6 +135,18 @@ struct BlurStyleOption {
|
||||
}
|
||||
};
|
||||
|
||||
struct EffectOption {
|
||||
Dimension radius;
|
||||
double saturation { 1.0f };
|
||||
double brightness { 1.0f };
|
||||
Color color { Color::TRANSPARENT };
|
||||
bool operator == (const EffectOption& other) const
|
||||
{
|
||||
return radius == other.radius && NearEqual(saturation, other.saturation) &&
|
||||
NearEqual(brightness, other.brightness) && color == other.color;
|
||||
}
|
||||
};
|
||||
|
||||
struct PixStretchEffectOption {
|
||||
Dimension left;
|
||||
Dimension top;
|
||||
|
@ -42,7 +42,12 @@ constexpr int32_t WINDOW_MAX_RECOVER_BUTTON = ROOT_DECOR_BASE + 6;
|
||||
constexpr int32_t WINDOW_MINIMIZE_BUTTON = ROOT_DECOR_BASE + 8;
|
||||
constexpr int32_t WINDOW_CLOSE_BUTTON = ROOT_DECOR_BASE + 10;
|
||||
constexpr int32_t WINDOW_BUTTON_INVALID = ROOT_DECOR_BASE + 12;
|
||||
}
|
||||
|
||||
const std::string SPLIT_LEFT_KEY = "container_modal_split_left_button";
|
||||
const std::string MAXIMIZE_KEY = "container_modal_maximize_button";
|
||||
const std::string MINIMIZE_KEY = "container_modal_minimize_button";
|
||||
const std::string CLOSE_KEY = "container_modal_close_button";
|
||||
} // namespace
|
||||
|
||||
RefPtr<Component> ContainerModalComponent::Create(
|
||||
const WeakPtr<PipelineContext>& context, const RefPtr<Component>& child)
|
||||
@ -143,17 +148,21 @@ RefPtr<Component> ContainerModalComponent::BuildContent()
|
||||
RefPtr<Component> ContainerModalComponent::BuildControlButton(
|
||||
InternalResource::ResourceId icon, std::function<void()>&& clickCallback, bool isFocus, bool isFloating)
|
||||
{
|
||||
static std::map<InternalResource::ResourceId, int32_t> controlButtonIdMap = {
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_SPLIT_LEFT, WINDOW_SPLIT_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_SPLIT_LEFT, WINDOW_SPLIT_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_RECOVER, WINDOW_MAX_RECOVER_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_MAXIMIZE, WINDOW_MAX_RECOVER_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_RECOVER, WINDOW_MAX_RECOVER_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_MAXIMIZE, WINDOW_MAX_RECOVER_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_MINIMIZE, WINDOW_MINIMIZE_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_MINIMIZE, WINDOW_MINIMIZE_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_CLOSE, WINDOW_CLOSE_BUTTON },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_CLOSE, WINDOW_CLOSE_BUTTON },
|
||||
static std::unordered_map<InternalResource::ResourceId, std::pair<int32_t, std::string>> controlButtonIdMap = {
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_SPLIT_LEFT, { WINDOW_SPLIT_BUTTON, SPLIT_LEFT_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_SPLIT_LEFT,
|
||||
{ WINDOW_SPLIT_BUTTON, SPLIT_LEFT_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_RECOVER, { WINDOW_MAX_RECOVER_BUTTON, MAXIMIZE_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_MAXIMIZE, { WINDOW_MAX_RECOVER_BUTTON, MAXIMIZE_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_RECOVER,
|
||||
{ WINDOW_MAX_RECOVER_BUTTON, MAXIMIZE_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_MAXIMIZE,
|
||||
{ WINDOW_MAX_RECOVER_BUTTON, MAXIMIZE_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_MINIMIZE, { WINDOW_MINIMIZE_BUTTON, MINIMIZE_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_MINIMIZE,
|
||||
{ WINDOW_MINIMIZE_BUTTON, MINIMIZE_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_CLOSE, { WINDOW_CLOSE_BUTTON, CLOSE_KEY } },
|
||||
{ InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_DEFOCUS_CLOSE, { WINDOW_CLOSE_BUTTON, CLOSE_KEY } },
|
||||
};
|
||||
|
||||
auto image = AceType::MakeRefPtr<ImageComponent>(icon);
|
||||
@ -171,12 +180,17 @@ RefPtr<Component> ContainerModalComponent::BuildControlButton(
|
||||
button->SetClickedColor(TITLE_BUTTON_CLICKED_COLOR);
|
||||
button->SetClickFunction(std::move(clickCallback));
|
||||
button->SetFocusable(false);
|
||||
|
||||
std::string buttonKey = "";
|
||||
auto iter = controlButtonIdMap.find(icon);
|
||||
if (iter != controlButtonIdMap.end()) {
|
||||
buttonKey = (iter->second).second;
|
||||
}
|
||||
button->SetInspectorKey(buttonKey.c_str());
|
||||
if (!isDeclarative_) {
|
||||
auto buttonId = WINDOW_BUTTON_INVALID;
|
||||
auto iter = controlButtonIdMap.find(icon);
|
||||
if (iter != controlButtonIdMap.end()) {
|
||||
buttonId = isFloating ? iter->second + 1 : iter->second;
|
||||
buttonId = isFloating ? (iter->second).first + 1 : (iter->second).first;
|
||||
}
|
||||
CreateAccessibilityNode(DOM_NODE_TAG_BUTTON, buttonId, isFloating ? FLOATING_TITLE_ROW : TITLE_ROW);
|
||||
return AceType::MakeRefPtr<ComposedComponent>(std::to_string(buttonId), DOM_NODE_TAG_BUTTON, button);
|
||||
|
@ -451,17 +451,11 @@ void RosenRenderImage::UpdateSharedMemoryImage(const RefPtr<PipelineContext>& co
|
||||
return;
|
||||
}
|
||||
auto nameOfSharedImage = ImageLoader::RemovePathHead(sourceInfo_.GetSrc());
|
||||
if (sharedImageManager->RegisterLoader(nameOfSharedImage, AceType::WeakClaim(this))) {
|
||||
// This case means that the image to load is a memory image and its data is not ready.
|
||||
// Add [this] to [providerMapToReload_] so that it will be notified to start loading image.
|
||||
// When the data is ready, [SharedImageManager] will call [UpdateData] in [AddImageData].
|
||||
return;
|
||||
}
|
||||
// this is when current picName is not found in [ProviderMapToReload], indicating that image data of this
|
||||
// image may have been written to [SharedImageMap], so start loading
|
||||
if (sharedImageManager->FindImageInSharedImageMap(nameOfSharedImage, AceType::WeakClaim(this))) {
|
||||
return;
|
||||
}
|
||||
sharedImageManager->RegisterLoader(nameOfSharedImage, AceType::WeakClaim(this));
|
||||
// This case means that the image to load is a memory image.
|
||||
// Add [this] to [providerMapToReload_] so that it will be notified to start loading image.
|
||||
// When the data is ready, [SharedImageManager] will call [UpdateData] in [AddImageData].
|
||||
sharedImageManager->FindImageInSharedImageMap(nameOfSharedImage, AceType::WeakClaim(this));
|
||||
}
|
||||
|
||||
void RosenRenderImage::PerformLayoutPixmap()
|
||||
|
@ -988,7 +988,7 @@ void Scrollable::StartSpringMotion(
|
||||
|
||||
void Scrollable::ProcessScrollMotionStop()
|
||||
{
|
||||
if (needScrollSnapChange_ && calePredictSnapOffsetCallback_) {
|
||||
if (needScrollSnapChange_ && calePredictSnapOffsetCallback_ && motion_) {
|
||||
needScrollSnapChange_ = false;
|
||||
auto predictSnapOffset = calePredictSnapOffsetCallback_(motion_->GetFinalPosition() - currentPos_);
|
||||
if (predictSnapOffset.has_value() && !NearZero(predictSnapOffset.value())) {
|
||||
@ -1107,7 +1107,7 @@ bool Scrollable::HandleOverScroll(double velocity)
|
||||
{
|
||||
auto parent = parent_.Upgrade();
|
||||
if (!parent || !nestedOpt_.NeedParent()) {
|
||||
if (edgeEffect_ != EdgeEffect::NONE) {
|
||||
if (edgeEffect_ == EdgeEffect::SPRING) {
|
||||
ProcessScrollOverCallback(velocity);
|
||||
return true;
|
||||
}
|
||||
@ -1125,14 +1125,14 @@ bool Scrollable::HandleOverScroll(double velocity)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (edgeEffect_ != EdgeEffect::NONE) {
|
||||
if (edgeEffect_ == EdgeEffect::SPRING) {
|
||||
ProcessScrollOverCallback(velocity);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// self handle over scroll first
|
||||
if (edgeEffect_ != EdgeEffect::NONE) {
|
||||
if (edgeEffect_ == EdgeEffect::SPRING) {
|
||||
ProcessScrollOverCallback(velocity);
|
||||
return true;
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ constexpr double SELECT_OPTION_TOP_LENGTH = 15.0;
|
||||
constexpr double SELECT_OPTION_RIGHT_LENGTH = 16.0;
|
||||
constexpr double SELECT_OPTION_BOTTOM_LENGTH = 15.0;
|
||||
constexpr Dimension VERTICAL_INTERVAL = 14.4_vp;
|
||||
constexpr Dimension MENU_END_ICON_WIDTH = 12.0_vp;
|
||||
constexpr Dimension MENU_END_ICON_HEIGHT = 24.0_vp;
|
||||
|
||||
/**
|
||||
* SelectTheme defines color and styles of SelectComponent. SelectTheme should be build
|
||||
@ -188,6 +190,8 @@ public:
|
||||
theme->selectMinWidth_ = pattern->GetAttr<Dimension>("select_min_width", theme->selectMinWidth_);
|
||||
theme->selectDefaultHeight_ = pattern->GetAttr<Dimension>("select_min_height", theme->selectDefaultHeight_);
|
||||
theme->iconSideLength_ = pattern->GetAttr<Dimension>("icon_side_length", theme->iconSideLength_);
|
||||
theme->endIconWidth_ = MENU_END_ICON_WIDTH;
|
||||
theme->endIconHeight_ = MENU_END_ICON_HEIGHT;
|
||||
theme->contentMargin_ = pattern->GetAttr<Dimension>("content_margin", theme->contentMargin_);
|
||||
}
|
||||
};
|
||||
@ -276,6 +280,8 @@ public:
|
||||
theme->selectMinWidth_ = selectMinWidth_;
|
||||
theme->selectDefaultHeight_ = selectDefaultHeight_;
|
||||
theme->iconSideLength_ = iconSideLength_;
|
||||
theme->endIconWidth_ = endIconWidth_;
|
||||
theme->endIconHeight_ = endIconHeight_;
|
||||
theme->contentMargin_ = contentMargin_;
|
||||
return theme;
|
||||
}
|
||||
@ -789,6 +795,16 @@ public:
|
||||
return iconSideLength_;
|
||||
}
|
||||
|
||||
const Dimension& GetEndIconWidth() const
|
||||
{
|
||||
return endIconWidth_;
|
||||
}
|
||||
|
||||
const Dimension& GetEndIconHeight() const
|
||||
{
|
||||
return endIconHeight_;
|
||||
}
|
||||
|
||||
const Dimension& GetContentMargin() const
|
||||
{
|
||||
return contentMargin_;
|
||||
@ -865,6 +881,8 @@ private:
|
||||
Dimension selectMinWidth_;
|
||||
Dimension selectDefaultHeight_;
|
||||
Dimension iconSideLength_;
|
||||
Dimension endIconWidth_;
|
||||
Dimension endIconHeight_;
|
||||
Dimension contentMargin_;
|
||||
|
||||
Color tvFocusTextColor_;
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
|
||||
static constexpr Color BLOCK_COLOR_PRESSED = Color(0x19182431);
|
||||
static constexpr Color BLOCK_OUTER_EDGE_COLOR = Color(0x0A000000);
|
||||
static constexpr Color BLOCK_SHADOW_COLOR = Color(0x26000000);
|
||||
static constexpr Dimension BUBBLE_TO_CIRCLE_CENTER_DISTANCE = 20.0_vp;
|
||||
static constexpr Dimension MEASURE_CONTENT_DEFAULT_WIDTH = 40.0_vp;
|
||||
static constexpr Dimension OUTSET_HOT_BLOCK_SHADOW_WIDTH = 4.0_vp;
|
||||
@ -68,6 +69,7 @@ public:
|
||||
theme->tipFontSize_ = themeConstants->GetDimension(THEME_SLIDER_TIP_FONT_SIZE);
|
||||
theme->tipTextPadding_ = themeConstants->GetDimension(THEME_SLIDER_TIP_TEXT_PADDING_SIZE);
|
||||
theme->blockHoverColor_ = themeConstants->GetColor(THEME_SLIDER_BLOCK_HOVER_COLOR);
|
||||
theme->blockShadowColor_ = BLOCK_SHADOW_COLOR;
|
||||
ParsePattern(themeConstants->GetThemeStyle(), theme);
|
||||
return theme;
|
||||
}
|
||||
@ -223,6 +225,11 @@ public:
|
||||
return trackSelectedColor_;
|
||||
}
|
||||
|
||||
Color GetBlockShadowColor() const
|
||||
{
|
||||
return blockShadowColor_;
|
||||
}
|
||||
|
||||
Dimension GetFocusSideDistance() const
|
||||
{
|
||||
return focusSideDistance_;
|
||||
@ -279,6 +286,7 @@ private:
|
||||
Color markerColor_;
|
||||
Color trackBgColor_;
|
||||
Color trackSelectedColor_;
|
||||
Color blockShadowColor_;
|
||||
|
||||
// others
|
||||
Dimension focusSideDistance_;
|
||||
|
@ -26,10 +26,10 @@ RefPtr<Frontend> Frontend::CreateDefault()
|
||||
return AceType::MakeRefPtr<JsonFrontend>();
|
||||
}
|
||||
|
||||
bool JsonFrontend::Initialize(FrontendType type, const RefPtr<TaskExecutor>&)
|
||||
bool JsonFrontend::Initialize(FrontendType type, const RefPtr<TaskExecutor>& taskExecutor)
|
||||
{
|
||||
// This interface is inherited from base class 'Frontend', but we never use 'TaskExecutor'.
|
||||
type_ = type;
|
||||
taskExecutor_ = taskExecutor;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -120,11 +120,6 @@ public:
|
||||
return windowConfig_;
|
||||
}
|
||||
|
||||
FrontendType GetType() override
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
void SendCallbackMessage(const std::string& callbackId, const std::string& data) const override
|
||||
{
|
||||
// maybe will implement later
|
||||
@ -172,7 +167,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
FrontendType type_ { FrontendType::JSON };
|
||||
static constexpr int32_t JSON_DESIGN_WIDTH = 1080;
|
||||
std::unordered_map<int, RefPtr<AcePage>> pageMap_;
|
||||
RefPtr<PipelineBase> pipelineContext_;
|
||||
|
@ -4482,6 +4482,10 @@ bool WebDelegate::IsImageDrag()
|
||||
|
||||
std::shared_ptr<OHOS::NWeb::NWebDragData> WebDelegate::GetOrCreateDragData()
|
||||
{
|
||||
if (dragData_) {
|
||||
return dragData_;
|
||||
}
|
||||
|
||||
if (nweb_) {
|
||||
dragData_ = nweb_->GetOrCreateDragData();
|
||||
return dragData_;
|
||||
|
@ -202,6 +202,7 @@ public:
|
||||
{
|
||||
SetAllChildrenInActive();
|
||||
ResetChildren();
|
||||
Build();
|
||||
for (const auto& child : children_) {
|
||||
child.node->DoRemoveChildInRenderTree(0, true);
|
||||
}
|
||||
@ -727,6 +728,7 @@ void FrameNode::SwapDirtyLayoutWrapperOnMainThread(const RefPtr<LayoutWrapper>&
|
||||
SetBackgroundLayoutConstraint(columnNode);
|
||||
renderContext_->CreateBackgroundPixelMap(columnNode);
|
||||
builderFunc_ = nullptr;
|
||||
backgroundNode_ = columnNode;
|
||||
}
|
||||
|
||||
// update focus state
|
||||
@ -963,11 +965,6 @@ std::optional<UITask> FrameNode::CreateLayoutTask(bool forceUseMainThread)
|
||||
ACE_SCOPED_TRACE("Layout");
|
||||
Layout();
|
||||
}
|
||||
{
|
||||
LayoutWrapper::SaveGeoState();
|
||||
LayoutWrapper::AvoidKeyboard();
|
||||
LayoutWrapper::ExpandSafeArea();
|
||||
}
|
||||
SetRootMeasureNode(false);
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -1835,12 +1832,7 @@ OffsetF FrameNode::GetParentGlobalOffsetDuringLayout() const
|
||||
OffsetF offset {};
|
||||
auto parent = GetAncestorNodeOfFrame();
|
||||
while (parent) {
|
||||
auto wrapper = parent->layoutWrapper_.Upgrade();
|
||||
if (wrapper) {
|
||||
offset += wrapper->GetGeometryNode()->GetFrameOffset();
|
||||
} else {
|
||||
offset += parent->geometryNode_->GetFrameOffset();
|
||||
}
|
||||
offset += parent->geometryNode_->GetFrameOffset();
|
||||
parent = parent->GetAncestorNodeOfFrame();
|
||||
}
|
||||
return offset;
|
||||
@ -2149,8 +2141,8 @@ bool FrameNode::HaveSecurityComponent()
|
||||
|
||||
bool FrameNode::IsSecurityComponent()
|
||||
{
|
||||
return GetTag() == V2::SEC_LOCATION_BUTTON_ETS_TAG || GetTag() == V2::SEC_PASTE_BUTTON_ETS_TAG ||
|
||||
GetTag() == V2::SEC_SAVE_BUTTON_ETS_TAG;
|
||||
return GetTag() == V2::LOCATION_BUTTON_ETS_TAG || GetTag() == V2::PASTE_BUTTON_ETS_TAG ||
|
||||
GetTag() == V2::SAVE_BUTTON_ETS_TAG;
|
||||
}
|
||||
|
||||
void FrameNode::OnSetDepth(const int32_t depth)
|
||||
@ -2164,6 +2156,9 @@ void FrameNode::OnSetDepth(const int32_t depth)
|
||||
// This will call child and self measure process.
|
||||
void FrameNode::Measure(const std::optional<LayoutConstraintF>& parentConstraint)
|
||||
{
|
||||
if (!oldGeometryNode_) {
|
||||
oldGeometryNode_ = geometryNode_->Clone();
|
||||
}
|
||||
RestoreGeoState();
|
||||
pattern_->BeforeCreateLayoutWrapper();
|
||||
GetLayoutAlgorithm(true);
|
||||
@ -2257,14 +2252,6 @@ void FrameNode::Measure(const std::optional<LayoutConstraintF>& parentConstraint
|
||||
void FrameNode::Layout()
|
||||
{
|
||||
int64_t time = GetSysTimestamp();
|
||||
auto&& expandOpts = layoutProperty_->GetSafeAreaExpandOpts();
|
||||
if ((expandOpts && expandOpts->Expansive()) || GetTag() == V2::PAGE_ETS_TAG) {
|
||||
// record expansive wrappers during Layout traversal to speed up SafeArea expansion
|
||||
// Page node needs to avoid keyboard, record it too.
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
pipeline->GetSafeAreaManager()->AddWrapper(WeakClaim(this));
|
||||
}
|
||||
OffsetNodeToSafeArea();
|
||||
if (CheckNeedLayout(layoutProperty_->GetPropertyChangeFlag())) {
|
||||
if (!layoutProperty_->GetLayoutConstraint()) {
|
||||
@ -2290,6 +2277,10 @@ void FrameNode::Layout()
|
||||
GetLayoutAlgorithm()->SetSkipLayout();
|
||||
}
|
||||
|
||||
SaveGeoState();
|
||||
AvoidKeyboard();
|
||||
ExpandSafeArea();
|
||||
|
||||
LOGD("On Layout Done: type: %{public}s, depth: %{public}d, Offset: %{public}s", GetTag().c_str(), GetDepth(),
|
||||
geometryNode_->GetFrameOffset().ToString().c_str());
|
||||
SyncGeometryNode();
|
||||
|
@ -357,6 +357,7 @@ public:
|
||||
void SetBackgroundFunction(std::function<RefPtr<UINode>()>&& buildFunc)
|
||||
{
|
||||
builderFunc_ = buildFunc;
|
||||
backgroundNode_ = nullptr;
|
||||
}
|
||||
|
||||
bool IsDraggable() const
|
||||
@ -405,16 +406,6 @@ public:
|
||||
|
||||
static std::vector<RefPtr<FrameNode>> GetNodesById(const std::unordered_set<int32_t>& set);
|
||||
|
||||
// called during LayoutWrapper creation, used for finding corresponding LayoutWrapper during RestoreGeoState
|
||||
void RecordLayoutWrapper(WeakPtr<LayoutWrapper> layoutWrapper)
|
||||
{
|
||||
layoutWrapper_ = std::move(layoutWrapper);
|
||||
}
|
||||
const WeakPtr<LayoutWrapper>& GetLayoutWrapper() const
|
||||
{
|
||||
return layoutWrapper_;
|
||||
}
|
||||
|
||||
void SetViewPort(RectF viewPort)
|
||||
{
|
||||
viewPort_ = viewPort;
|
||||
@ -568,9 +559,8 @@ private:
|
||||
RefPtr<RenderContext> renderContext_ = RenderContext::Create();
|
||||
RefPtr<EventHub> eventHub_;
|
||||
RefPtr<Pattern> pattern_;
|
||||
// only valid during layout task
|
||||
WeakPtr<LayoutWrapper> layoutWrapper_;
|
||||
|
||||
RefPtr<FrameNode> backgroundNode_;
|
||||
std::function<RefPtr<UINode>()> builderFunc_;
|
||||
std::unique_ptr<RectF> lastFrameRect_;
|
||||
std::unique_ptr<OffsetF> lastParentOffsetToWindow_;
|
||||
|
@ -451,7 +451,9 @@ void UINode::DumpTree(int32_t depth)
|
||||
void UINode::AdjustLayoutWrapperTree(const RefPtr<LayoutWrapperNode>& parent, bool forceMeasure, bool forceLayout)
|
||||
{
|
||||
for (const auto& child : children_) {
|
||||
child->AdjustLayoutWrapperTree(parent, forceMeasure, forceLayout);
|
||||
if (!child->IsInDestroying()) {
|
||||
child->AdjustLayoutWrapperTree(parent, forceMeasure, forceLayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,6 +257,20 @@ void ViewAbstract::SetBackgroundBlurStyle(const BlurStyleOption& bgBlurStyle)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewAbstract::SetBackgroundEffect(const EffectOption& effectOption)
|
||||
{
|
||||
if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
|
||||
LOGD("current state is not processed, return");
|
||||
return;
|
||||
}
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto target = frameNode->GetRenderContext();
|
||||
if (target) {
|
||||
target->UpdateBackgroundEffect(effectOption);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewAbstract::SetForegroundBlurStyle(const BlurStyleOption& fgBlurStyle)
|
||||
{
|
||||
if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
|
||||
@ -1091,6 +1105,7 @@ void ViewAbstract::BindPopup(
|
||||
LOGI("Popup now show in subwindow.");
|
||||
SubwindowManager::GetInstance()->ShowPopupNG(targetId, popupInfo);
|
||||
if (popupPattern) {
|
||||
popupPattern->SetContainerId(Container::CurrentId());
|
||||
popupPattern->StartEnteringAnimation(nullptr);
|
||||
}
|
||||
} else {
|
||||
@ -1156,11 +1171,6 @@ void ViewAbstract::BindMenuWithCustomNode(const RefPtr<UINode>& customNode, cons
|
||||
// unable to use the subWindow in the Previewer.
|
||||
isContextMenu = false;
|
||||
#endif
|
||||
// windowScene will not use subwindow
|
||||
auto container = Container::Current();
|
||||
if (container && container->IsScenceBoardWindow()) {
|
||||
isContextMenu = false;
|
||||
}
|
||||
auto type = isContextMenu ? MenuType::CONTEXT_MENU : MenuType::MENU;
|
||||
auto menuNode = MenuView::Create(customNode, targetNode->GetId(), targetNode->GetTag(), type, menuParam);
|
||||
if (isContextMenu) {
|
||||
|
@ -96,6 +96,7 @@ public:
|
||||
static void SetBackgroundImageSize(const BackgroundImageSize& bgImgSize);
|
||||
static void SetBackgroundImagePosition(const BackgroundImagePosition& bgImgPosition);
|
||||
static void SetBackgroundBlurStyle(const BlurStyleOption& bgBlurStyle);
|
||||
static void SetBackgroundEffect(const EffectOption& effectOption);
|
||||
static void SetForegroundBlurStyle(const BlurStyleOption& fgBlurStyle);
|
||||
static void SetSphericalEffect(double radio);
|
||||
static void SetPixelStretchEffect(PixStretchEffectOption& option);
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
virtual void SetBackgroundImageSize(const BackgroundImageSize& bgImgSize) = 0;
|
||||
virtual void SetBackgroundImagePosition(const BackgroundImagePosition& bgImgPosition) = 0;
|
||||
virtual void SetBackgroundBlurStyle(const BlurStyleOption& bgBlurStyle) = 0;
|
||||
virtual void SetBackgroundEffect(const EffectOption& effectOption) {}
|
||||
virtual void SetForegroundBlurStyle(const BlurStyleOption& fgBlurStyle) {}
|
||||
virtual void SetSphericalEffect(double radio) {}
|
||||
virtual void SetPixelStretchEffect(PixStretchEffectOption& option) {}
|
||||
|
@ -134,6 +134,11 @@ public:
|
||||
ViewAbstract::SetBackgroundBlurStyle(bgBlurStyle);
|
||||
}
|
||||
|
||||
void SetBackgroundEffect(const EffectOption& effectOption) override
|
||||
{
|
||||
ViewAbstract::SetBackgroundEffect(effectOption);
|
||||
}
|
||||
|
||||
void SetForegroundBlurStyle(const BlurStyleOption& fgBlurStyle) override
|
||||
{
|
||||
ViewAbstract::SetForegroundBlurStyle(fgBlurStyle);
|
||||
|
@ -136,6 +136,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co
|
||||
HideEventColumn();
|
||||
HidePixelMap(true, info.GetGlobalLocation().GetX(), info.GetGlobalLocation().GetY());
|
||||
HideFilter();
|
||||
SubwindowManager::GetInstance()->HideMenuNG();
|
||||
AnimationOption option;
|
||||
option.SetDuration(PIXELMAP_ANIMATION_DURATION);
|
||||
option.SetCurve(Curves::SHARP);
|
||||
@ -144,15 +145,6 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co
|
||||
[renderContext]() {
|
||||
renderContext->UpdateOpacity(SCALE_NUMBER);
|
||||
}, option.GetOnFinishEvent());
|
||||
auto container = Container::Current();
|
||||
if (container && container->IsScenceBoardWindow()) {
|
||||
auto pipelineContext = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipelineContext);
|
||||
auto manager = pipelineContext->GetOverlayManager();
|
||||
manager->HideAllMenus();
|
||||
} else {
|
||||
SubwindowManager::GetInstance()->HideMenuNG();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,6 +208,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co
|
||||
LOGE("InteractionManager: UpdateShadowPic error");
|
||||
return;
|
||||
}
|
||||
LOGD("Drag window start for Mouse with default pixelMap");
|
||||
Msdp::DeviceStatus::InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
};
|
||||
auto gestureHub = gestureEventHub_.Upgrade();
|
||||
@ -467,6 +460,23 @@ void DragEventActuator::SetFilter(const RefPtr<DragEventActuator>& actuator)
|
||||
}
|
||||
}
|
||||
|
||||
OffsetF DragEventActuator::GetFloatImageOffset(const RefPtr<FrameNode>& frameNode)
|
||||
{
|
||||
auto offsetToWindow = frameNode->GetPaintRectOffset();
|
||||
auto offsetX = offsetToWindow.GetX();
|
||||
auto offsetY = offsetToWindow.GetY();
|
||||
#ifdef WEB_SUPPORTED
|
||||
if (frameNode->GetTag() == V2::WEB_ETS_TAG) {
|
||||
auto webPattern = frameNode->GetPattern<WebPattern>();
|
||||
if (webPattern) {
|
||||
offsetX += webPattern->GetDragOffset().GetX();
|
||||
offsetY += webPattern->GetDragOffset().GetY();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return OffsetF(offsetX, offsetY);
|
||||
}
|
||||
|
||||
void DragEventActuator::SetPixelMap(const RefPtr<DragEventActuator>& actuator)
|
||||
{
|
||||
auto pipelineContext = PipelineContext::GetCurrentContext();
|
||||
@ -484,13 +494,8 @@ void DragEventActuator::SetPixelMap(const RefPtr<DragEventActuator>& actuator)
|
||||
CHECK_NULL_VOID(pixelMap);
|
||||
auto width = pixelMap->GetWidth();
|
||||
auto height = pixelMap->GetHeight();
|
||||
auto offsetToWindow = frameNode->GetPaintRectOffset();
|
||||
auto offsetX = offsetToWindow.GetX();
|
||||
auto offsetY = offsetToWindow.GetY();
|
||||
if (frameNode->GetTag() == V2::WEB_ETS_TAG) {
|
||||
offsetX = longPressInfo_.GetGlobalPoint().GetX() - (width / 2);
|
||||
offsetY = longPressInfo_.GetGlobalPoint().GetY() - (height / 2);
|
||||
}
|
||||
auto offsetX = GetFloatImageOffset(frameNode).GetX();
|
||||
auto offsetY = GetFloatImageOffset(frameNode).GetY();
|
||||
// create imageNode
|
||||
auto imageNode = FrameNode::GetOrCreateFrameNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
|
||||
[]() { return AceType::MakeRefPtr<ImagePattern>(); });
|
||||
@ -679,6 +684,7 @@ void DragEventActuator::GetTextPixelMap(bool startDrag)
|
||||
LOGE("InteractionManager: UpdateShadowPic error");
|
||||
return;
|
||||
}
|
||||
LOGD("Drag window start for Mouse with Text");
|
||||
Msdp::DeviceStatus::InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
gestureHub->SetPixelMap(nullptr);
|
||||
}
|
||||
@ -741,6 +747,7 @@ void DragEventActuator::HideTextAnimation(bool startDrag, double globalX, double
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->CreateHandles();
|
||||
}
|
||||
LOGD("Drag window start for Text");
|
||||
Msdp::DeviceStatus::InteractionManager::GetInstance()->SetDragWindowVisible(true);
|
||||
auto gestureHub = weakEvent.Upgrade();
|
||||
CHECK_NULL_VOID(gestureHub);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user