fix cj frontend error

Signed-off-by: cuitengfei <cuitengfei3@huawei.com>
Change-Id: I5337c15912baa3163a8e2bc1e41c30f682a0e3d9
This commit is contained in:
cuitengfei 2024-06-06 23:33:21 +08:00
parent 7980daf377
commit c426fba4e9
40 changed files with 527 additions and 116 deletions

View File

@ -1520,7 +1520,9 @@ UIContentErrorCode UIContentImpl::CommonInitialize(
auto token = context->GetToken();
container->SetToken(token);
container->SetParentToken(parentToken_);
container->SetPageUrlChecker(AceType::MakeRefPtr<PageUrlCheckerOhos>(context, info));
if (!isCJFrontend) {
container->SetPageUrlChecker(AceType::MakeRefPtr<PageUrlCheckerOhos>(context, info));
}
container->SetNavigationRoute(AceType::MakeRefPtr<NavigationRouteOhos>(context->GetBundleName()));
// Mark the relationship between windowId and containerId, it is 1:1
SubwindowManager::GetInstance()->AddContainerId(window->GetWindowId(), instanceId_);
@ -1529,6 +1531,8 @@ UIContentErrorCode UIContentImpl::CommonInitialize(
if (runtime_) {
container->GetSettings().SetUsingSharedRuntime(true);
container->SetSharedRuntime(runtime_);
} else if (isCJFrontend) {
container->GetSettings().SetUsingSharedRuntime(true);
} else {
container->GetSettings().SetUsingSharedRuntime(false);
}

View File

@ -223,6 +223,9 @@
OHOS::Ace::PipelineBase::PrepareOpenImplicitAnimation*;
OHOS::Ace::PipelineBase::PrepareCloseImplicitAnimation*;
OHOS::Ace::PipelineBase::GetCurrentDensity*;
OHOS::Ace::PipelineBase::RegisterFont*;
OHOS::Ace::PipelineBase::GetSystemFontList*;
OHOS::Ace::PipelineBase::GetSystemFont*;
OHOS::Ace::NG::ViewAbstract::*;
OHOS::Ace::NG::Inspector::*;
OHOS::Ace::V2::Inspector::*;
@ -239,6 +242,8 @@
OHOS::Ace::StorageProxy::*;
OHOS::Ace::EnvironmentProxy::*;
OHOS::Ace::AceScoringLog::*;
"OHOS::Ace::NG::CustomNode::FlushReload()";
"OHOS::Ace::CanvasModel::GetInstance()";
virtual?thunk?to?OHOS::Ace::Animator::~Animator??;
virtual?thunk?to?OHOS::Ace::Frontend::MaybeRelease*;
@ -273,6 +278,7 @@
vtable?for?OHOS::Ace::NG::SwipeGesture;
vtable?for?OHOS::Ace::NG::PanGesture;
vtable?for?OHOS::Ace::NG::GestureGroup;
vtable?for?OHOS::Ace::NG::CanvasRenderingContext2DModelNG;
VTT?for?OHOS::Ace::Animator;
VTT?for?OHOS::Ace::Container;
@ -293,6 +299,7 @@
VTT?for?OHOS::Ace::NG::SwipeGesture;
VTT?for?OHOS::Ace::NG::PanGesture;
VTT?for?OHOS::Ace::NG::GestureGroup;
VTT?for?OHOS::Ace::NG::CanvasRenderingContext2DModelNG;
OHOS::Ace::AceScopedTraceFlag::*;
OHOS::Ace::AnimationUtils::*;

View File

@ -61,6 +61,9 @@ template("cj_frontend") {
}
sources += [
"cppview/canvas_gradient.cpp",
"cppview/canvas_path.cpp",
"cppview/canvas_renderer.cpp",
"cppview/data_change_listener.cpp",
"cppview/gesture.cpp",
"cppview/interactable_view.cpp",
@ -81,6 +84,7 @@ template("cj_frontend") {
"interfaces/cj_ffi/cj_badge_ffi.cpp",
"interfaces/cj_ffi/cj_blank_ffi.cpp",
"interfaces/cj_ffi/cj_button_ffi.cpp",
"interfaces/cj_ffi/cj_canvas_ffi.cpp",
"interfaces/cj_ffi/cj_checkbox_ffi.cpp",
"interfaces/cj_ffi/cj_checkbox_group_ffi.cpp",
"interfaces/cj_ffi/cj_circle_ffi.cpp",
@ -171,6 +175,7 @@ template("cj_frontend") {
"interfaces/cj_ffi/cj_view_context_ffi.cpp",
"interfaces/cj_ffi/cj_view_stack_processor_ffi.cpp",
"interfaces/cj_ffi/concurrency/cj_concurrency_ffi.cpp",
"interfaces/cj_ffi/font/cj_font_ffi.cpp",
"interfaces/cj_ffi/measure/cj_measure_ffi.cpp",
"interfaces/cj_ffi/prompt/cj_prompt_ffi.cpp",
"interfaces/cj_ffi/router/cj_router_ffi.cpp",
@ -200,7 +205,6 @@ template("cj_frontend") {
} else {
sources -= [
"interfaces/cj_ffi/cj_richeditor_controller_ffi.cpp",
"interfaces/cj_ffi/cj_richeditor_ffi.cpp",
"interfaces/cj_ffi/state_manage/cj_environment.cpp",
"interfaces/cj_ffi/state_manage/cj_persistent_storage_ffi.cpp",
]
@ -214,7 +218,17 @@ template("cj_frontend") {
if (defined(config.web_components_support) &&
config.web_components_support) {
sources += [ "interfaces/cj_ffi/cj_richtext_ffi.cpp" ]
external_deps += [
"ability_runtime:app_context",
"webview:cj_webview_ffi",
"webview:libnweb",
]
sources += [
"interfaces/cj_ffi/cj_richtext_ffi.cpp",
"interfaces/cj_ffi/cj_web_ffi.cpp",
]
} else {
sources += [ "interfaces/cj_ffi/mock/cj_web_mock.cpp" ]
}
if (defined(config.video_components_support) &&

View File

@ -154,6 +154,19 @@ void NativeView::MarkNeedUpdate()
}
}
void NativeView::FlushReload()
{
auto node = node_.Upgrade();
if (!node) {
LOGE("fail to update due to custom Node is null");
return;
}
if (AceType::InstanceOf<NG::CustomNode>(node)) {
auto customNode = AceType::DynamicCast<NG::CustomNode>(node);
customNode->FlushReload();
}
}
void NativeView::FinishUpdateFunc(int32_t elmtId)
{
LOGI("FinishUpdateFunc start");

View File

@ -87,6 +87,7 @@ public:
void SyncInstanceId();
void RestoreInstanceId();
void MarkNeedUpdate();
void FlushReload();
bool NeedsUpdate() const
{
return needsUpdate_;

View File

@ -27,6 +27,7 @@
#include "core/components/navigator/navigator_component.h"
#include "core/components_ng/pattern/overlay/overlay_manager.h"
#include "core/pipeline_ng/pipeline_context.h"
#include "core/common/font_manager.h"
using namespace OHOS::Ace::NG;
using namespace OHOS::Ace;
@ -41,7 +42,7 @@ constexpr int32_t CALLBACK_DATACODE_ZERO = 0;
// helper function to run OverlayManager task
// ensures that the task runs in subwindow instead of main Window
void MainWindowOverlay(std::function<void(RefPtr<NG::OverlayManager>)>&& task)
void MainWindowOverlay(std::function<void(RefPtr<NG::OverlayManager>)>&& task, const std::string& name)
{
auto currentId = Container::CurrentId();
ContainerScope scope(currentId);
@ -53,7 +54,7 @@ void MainWindowOverlay(std::function<void(RefPtr<NG::OverlayManager>)>&& task)
auto overlayManager = weak.Upgrade();
task(overlayManager);
},
TaskExecutor::TaskType::UI, "CJFroentendMainWindowOverlay");
TaskExecutor::TaskType::UI, name);
}
} // namespace
@ -95,6 +96,15 @@ bool CJFrontendAbstract::Initialize(FrontendType type, const RefPtr<OHOS::Ace::T
return true;
}
void CJFrontendAbstract::FlushReload()
{
if (!Container::IsCurrentUseNewPipeline()) {
LOGW("not support old pipeline");
return;
}
pageRouterManager_->FlushReload();
}
void CJFrontendAbstract::RebuildAllPages()
{
CHECK_NULL_VOID(pageRouterManager_);
@ -223,7 +233,7 @@ void CJFrontendAbstract::ShowToast(
ContainerScope scope(containerId);
overlayManager->ShowToast(message, durationTime, bottom, isRightToLeft, showMode);
};
MainWindowOverlay(std::move(task));
MainWindowOverlay(std::move(task), "ArkUIOverlayShowToast");
}
void CJFrontendAbstract::ShowDialog(const std::string& title, const std::string& message,
@ -266,7 +276,7 @@ void CJFrontendAbstract::ShowDialogInner(DialogProperties& dialogProperties,
CHECK_NULL_VOID(dialog);
}
};
MainWindowOverlay(std::move(task));
MainWindowOverlay(std::move(task), "ArkUIShowDialogInner");
}
void CJFrontendAbstract::ShowActionMenu(const std::string& title, const std::vector<ButtonInfo>& button,
@ -359,7 +369,7 @@ void CJFrontendAbstract::OpenCustomDialog(const PromptDialogAttr &dialogAttr,
overlayManager->OpenCustomDialog(dialogProperties, std::move(callback));
}
};
MainWindowOverlay(std::move(task));
MainWindowOverlay(std::move(task), "ArkUIOpenCustomDialog");
return;
}
@ -371,8 +381,46 @@ void CJFrontendAbstract::CloseCustomDialog(int32_t id)
overlayManager->CloseCustomDialog(id);
SubwindowManager::GetInstance()->CloseCustomDialogNG(id);
};
MainWindowOverlay(std::move(task));
MainWindowOverlay(std::move(task), "ArkUICloseCustomDialog");
return;
}
void CJFrontendAbstract::RegisterFont(const std::string& familyName, const std::string& familySrc,
const std::string& bundleName, const std::string& moduleName)
{
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc, bundleName, moduleName);
}
VectorStringHandle CJFrontendAbstract::GetSystemFontList()
{
auto fontList = new std::vector<std::string>;
pipelineContextHolder_.Get()->GetSystemFontList(*fontList);
return fontList;
}
NativeOptionFontInfo CJFrontendAbstract::GetSystemFont(const std::string& fontName)
{
auto fontInfo = new FontInfo;
if (!pipelineContextHolder_.Get()->GetSystemFont(fontName, *fontInfo)) {
return NativeOptionFontInfo {
.hasValue = false,
.info = nullptr
};
}
return NativeOptionFontInfo {
.hasValue = true,
.info = new NativeFontInfo {
.path = fontInfo->path.c_str(),
.postScriptName = fontInfo->postScriptName.c_str(),
.fullName = fontInfo->fullName.c_str(),
.family = fontInfo->family.c_str(),
.subfamily = fontInfo->subfamily.c_str(),
.weight = fontInfo->weight,
.width = fontInfo->width,
.italic = fontInfo->italic,
.monoSpace = fontInfo->monoSpace,
.symbolic = fontInfo->symbolic
}
};
}
} // namespace OHOS::Ace

View File

@ -22,6 +22,8 @@
#include "base/utils/measure_util.h"
#include "bridge/common/manifest/manifest_parser.h"
#include "bridge/common/utils/pipeline_context_holder.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_collection_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
#include "core/components_ng/pattern/overlay/overlay_manager.h"
#include "cj_page_router_abstract.h"
#include "core/common/frontend.h"
@ -47,7 +49,7 @@ public:
~CJFrontendAbstract() override;
bool Initialize(FrontendType type, const RefPtr<TaskExecutor>& taskExecutor) override;
void Destroy() override;
void FlushReload() override;
bool LoadAppLibrary();
void AttachPipelineContext(const RefPtr<PipelineBase>& context) override;
@ -110,6 +112,14 @@ public:
void ShowActionMenuInner(DialogProperties& dialogProperties, const std::vector<ButtonInfo>& button,
std::function<void(int32_t, int32_t)>&& callback);
// ----------------
// Font
// ----------------
void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
const std::string& moduleName = "");
VectorStringHandle GetSystemFontList();
NativeOptionFontInfo GetSystemFont(const std::string& fontName);
#if defined(PREVIEW)
void TransferJsResponseDataPreview(int32_t callbackId, int32_t code, ResponseData responseData) const;

View File

@ -41,6 +41,10 @@ public:
{
return loadingPage_;
}
void FlushReload() override
{
LOGE("not support in old pipeline");
}
protected:
void StartPush(const RouterPageInfo& target, const std::string& params, RouterMode mode) override;

View File

@ -61,7 +61,7 @@ public:
virtual std::string GetCurrentPageUrl() = 0;
virtual void EnableAlertBeforeBackPage(const std::string& message, std::function<void(int32_t)> callback) = 0;
virtual bool AllowPopLastPage() = 0;
virtual RefPtr<NG::FrameNode> GetCurrentPageNode() { return nullptr; }
virtual bool PopWithExitCheck();
void RunPage(const std::string& url, const std::string& params);
void Push(const RouterPageInfo& target, const std::string& params, RouterMode = RouterMode::STANDARD);
@ -69,12 +69,22 @@ public:
void Replace(const RouterPageInfo& target, const std::string& params, RouterMode = RouterMode::STANDARD);
void BackWithTarget(const RouterPageInfo& target, const std::string& params);
void Clear();
virtual void FlushReload() = 0;
void SetManifestParser(const RefPtr<Framework::ManifestParser>& manifestParser)
{
manifestParser_ = manifestParser;
}
std::list<int64_t> GetNativeViews()
{
return viewStack_;
}
void AddView(int64_t viewId)
{
viewStack_.emplace_back(viewId);
}
protected:
explicit CJPageRouterAbstract(WeakPtr<CJFrontendAbstract> frontend): frontend_(std::move(frontend)) {}
virtual void StartPush(const RouterPageInfo& target, const std::string& params,
@ -115,6 +125,7 @@ protected:
bool inRouterOpt_ = false;
RouterPageInfo ngBackUri_ = { "" };
std::string backParam_;
std::list<int64_t> viewStack_;
private:
int32_t nextPageId_ = 0;

View File

@ -109,6 +109,7 @@ bool LoadNativeViewNG(NativeView* view)
view->FireOnTransition();
NG::ViewStackProcessor::GetInstance()->SetPageNode(nullptr);
});
pageRouterManager->AddView(view->GetID());
LOGI("OHOSAceFrameworkNGLoadCJView end.");
return true;
}
@ -266,15 +267,18 @@ void CJPageRouterNG::StartClean()
bool CJPageRouterNG::StartPop()
{
ProcessGuard guard(this);
if (pageRouterStack_.size() <= 1) {
if (pageRouterStack_.size() <= 1 || viewStack_.size() <= 1) {
// the last page.
return false;
}
auto topNode = pageRouterStack_.back();
auto topView = viewStack_.back();
pageRouterStack_.pop_back();
viewStack_.pop_back();
if (!OnPopPage(true, true)) {
LOGE("fail to pop page.");
pageRouterStack_.emplace_back(topNode);
viewStack_.emplace_back(topView);
return false;
}
return true;
@ -546,7 +550,7 @@ void CJPageRouterNG::MovePageToFront(int32_t index, const RefPtr<FrameNode>& pag
void CJPageRouterNG::PopPage(const std::string& params, bool needShowNext, bool needTransition)
{
if (pageRouterStack_.empty()) {
if (pageRouterStack_.empty() || viewStack_.empty()) {
LOGE("page router stack size is illegal.");
return;
}
@ -555,11 +559,14 @@ void CJPageRouterNG::PopPage(const std::string& params, bool needShowNext, bool
return;
}
auto topNode = pageRouterStack_.back();
auto topView = viewStack_.back();
pageRouterStack_.pop_back();
viewStack_.pop_back();
if (params.empty()) {
if (!OnPopPage(needShowNext, needTransition)) {
LOGE("fail to pop page.");
pageRouterStack_.emplace_back(topNode);
viewStack_.emplace_back(topView);
}
return;
}
@ -579,6 +586,7 @@ void CJPageRouterNG::PopPage(const std::string& params, bool needShowNext, bool
LOGE("fail to pop page");
// restore stack and pageParam.
pageRouterStack_.emplace_back(topNode);
viewStack_.emplace_back(topView);
pageInfo->ReplacePageParams(temp);
}
@ -696,4 +704,11 @@ bool CJPageRouterNG::OnCleanPageStack()
return false;
}
void CJPageRouterNG::FlushReload()
{
for (const auto& viewId : viewStack_) {
auto view = FFI::FFIData::GetData<NativeView>(viewId);
view->FlushReload();
}
}
} // namespace OHOS::Ace::Framework

View File

@ -36,12 +36,14 @@ public:
bool PopWithExitCheck() override;
void FlushReload() override;
// router operation
int32_t GetStackSize() const override;
void GetState(int32_t& index, std::string& name, std::string& path) override;
std::string GetParams() const override;
RefPtr<NG::FrameNode> GetCurrentPageNode() const
RefPtr<NG::FrameNode> GetCurrentPageNode() override
{
if (pageRouterStack_.empty()) {
LOGE("fail to get current page node due to page is null");

View File

@ -18,19 +18,10 @@
#include <cstdint>
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_macro.h"
extern "C" {
struct NativeLength {
double value;
int32_t unitType;
};
struct NativeOffset {
NativeLength dx;
NativeLength dy;
};
struct NativeRectangle {
double x;
int32_t xUnit;

View File

@ -26,11 +26,34 @@
extern "C" {
struct NativeFontInfo {
const char* path = "";
const char* postScriptName = "";
const char* fullName = "" ;
const char* family = "";
const char* subfamily = "";
uint32_t weight = 0;
uint32_t width = 0;
bool italic = false;
bool monoSpace = false;
bool symbolic = false;
};
struct NativeOptionFontInfo {
bool hasValue;
NativeFontInfo* info;
};
struct NativeLength {
double value;
int32_t unitType;
};
struct NativeOffset {
NativeLength dx;
NativeLength dy;
};
struct NativeOptionLength {
bool hasValue;
NativeLength value;

View File

@ -20,6 +20,7 @@
#include <string>
#include "bridge/cj_frontend/cppview/native_view.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_macro.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_view_abstract_ffi.h"
#include "core/components/dialog/dialog_component.h"
@ -28,11 +29,6 @@
#include "cj_animate_param_ffi.h"
extern "C" {
struct NativeOffset {
NativeLength dx;
NativeLength dy;
};
struct NativeCustomDialogControllerOptions {
void(*cancel)();
bool autoCancel;

View File

@ -86,7 +86,7 @@ void FlexCreateFlexComponent(CJFlexParams params)
FlexModel::GetInstance()->SetMainAxisAlign(static_cast<FlexAlign>(justifyVal));
}
if (params.alignItems >= 0 && params.alignItems <= CROSS_ALIGN_MAX_VALUE) {
FlexModel::GetInstance()->SetCrossAxisAlign(static_cast<FlexAlign>(params.alignItems + 1));
FlexModel::GetInstance()->SetCrossAxisAlign(static_cast<FlexAlign>(params.alignItems));
}
}
void FlexCreateWrapComponent(CJFlexParams params)

View File

@ -29,14 +29,14 @@ using namespace OHOS::Ace::Framework;
extern "C" {
void FfiOHOSAceFrameworkForEachCreateFU(
char* viewId, int64_t parentViewID, int64_t dataSize, void (*callbackView)(int64_t), char* (*callbackKey)(int64_t))
char* viewId, int64_t parentViewID, int64_t dataSize, ViewCallBack callbackView, IdCallBack callbackKey)
{
std::function<void(int64_t)> ffiViewCallback = CJLambda::Create(callbackView);
std::function<std::string(int64_t)> ffiKeyCallback = [callback = CJLambda::Create(callbackKey)](
int64_t info) -> std::string {
char* ffiStr = callback(info);
std::string res = std::string(ffiStr);
free(ffiStr);
auto ffiStr = callback(info);
std::string res = ffiStr.value;
ffiStr.free(ffiStr.value);
return res;
};
auto* model = ForEachModel::GetInstance();

View File

@ -30,8 +30,11 @@ struct VectorToCFFIArrayString {
void (*free)(VectorToCFFIArrayString*);
};
typedef void (*ViewCallBack)(int64_t);
typedef ExternalString (*IdCallBack)(int64_t);
CJ_EXPORT void FfiOHOSAceFrameworkForEachCreateFU(
char* viewId, int64_t parentViewID, int64_t dataSize, void (*callbackView)(int64_t), char* (*callbackKey)(int64_t));
char* viewId, int64_t parentViewID, int64_t dataSize, ViewCallBack callbackView, IdCallBack callbackKey);
CJ_EXPORT void FfiOHOSAceFrameworkForEachCreate();
CJ_EXPORT void FfiOHOSAceFrameworkForEachPop();
CJ_EXPORT VectorToCFFIArrayString FfiOHOSAceFrameworkViewGetIdArray(int64_t elmtId);

View File

@ -96,6 +96,11 @@ void FfiOHOSAceFrameworkImageSetAlt(const char* url)
ImageModel::GetInstance()->SetAlt(ImageSourceInfo { url, bundleName, moduleName });
}
CJ_EXPORT void FfiOHOSAceFrameworkImageSetBorderRadius()
{
ImageModel::GetInstance()->SetBackBorder();
}
void FfiOHOSAceFrameworkImageSetObjectFit(int32_t objectFit)
{
if (!OHOS::Ace::Framework::Utils::CheckParamsValid(objectFit, IMAGE_FITS.size())) {

View File

@ -31,6 +31,7 @@ CJ_EXPORT void FfiOHOSAceFrameworkImageSetRenderMode(int32_t renderMode);
CJ_EXPORT void FfiOHOSAceFrameworkImageSetSourceSize(
double width, int32_t widthUnit, double height, int32_t heightUnit);
CJ_EXPORT void FfiOHOSAceFrameworkImageSetSyncLoad(bool syncLoad);
CJ_EXPORT void FfiOHOSAceFrameworkImageSetBorderRadius();
CJ_EXPORT void FfiOHOSAceFrameworkImageSetImageFill(uint32_t color);
CJ_EXPORT void FfiOHOSAceFrameworkImageSetAutoResize(bool autoResize);
CJ_EXPORT void FfiOHOSAceFrameworkImageSetMatchTextDirection(bool isMatchTextDirection);

View File

@ -196,6 +196,13 @@ void FfiOHOSAceFrameworkListSetSticky(int32_t style)
ListModel::GetInstance()->SetSticky(STICKY_STYLE[style]);
}
void FfiOHOSAceFrameworkListSetNestedScroll(int32_t scrollForward, int32_t scrollBackward)
{
NestedScrollOptions localNestedScrollOptions = {.forward = NestedScrollMode(scrollForward),
.backward = NestedScrollMode(scrollBackward)};
ListModel::GetInstance()->SetNestedScroll(localNestedScrollOptions);
}
void FfiOHOSAceFrameworkListSetCachedCount(int32_t cachedCount)
{
int32_t value = cachedCount < 0 ? 1 : cachedCount;

View File

@ -52,6 +52,7 @@ CJ_EXPORT void FfiOHOSAceFrameworkListSetLanesByLengthConstrain(
double min, int32_t minUnit, double max, int32_t maxUnit);
CJ_EXPORT void FfiOHOSAceFrameworkListSetAlignListItem(int32_t align);
CJ_EXPORT void FfiOHOSAceFrameworkListSetSticky(int32_t style);
CJ_EXPORT void FfiOHOSAceFrameworkListSetNestedScroll(int32_t scrollForward, int32_t scrollBackward);
CJ_EXPORT void FfiOHOSAceFrameworkListSetOnScrollFrameBegin(double (*callback)(double offset, int32_t state));
CJ_EXPORT void FfiOHOSAceFrameworkListSetItemDeleteCallback(bool (*callback)(int32_t value));
CJ_EXPORT void FfiOHOSAceFrameworkListSetScrollIndexCallback(void (*callback)(int32_t firstIndex, int32_t lastIndex));

View File

@ -98,7 +98,14 @@ void NativeRichEditorController::ParseRichEditorTextSpanResult(
nativeTextResult.offsetInSpanStart = spanObject.offsetInSpan[0];
nativeTextResult.offsetInSpanEnd = spanObject.offsetInSpan[1];
nativeTextResult.spanPosition = spanPosition;
nativeTextResult.value = spanObject.valueString.c_str();
auto len = spanObject.valueString.size() + 1;
char* cString = static_cast<char*>(malloc(sizeof(char) * len));
if (cString == nullptr) {
LOGE("ParseRichEditorTextSpanResult error, malloc cString failed");
return;
}
std::char_traits<char>::copy(cString, spanObject.valueString.c_str(), len);
nativeTextResult.value = cString;
}
void NativeRichEditorController::ParseRichEditorImageSpanResult(
@ -397,9 +404,17 @@ void NativeRichEditorController::UpdateSpanStyleImage(
richEditorController->UpdateSpanStyle(start, end, textStyle, imageStyle);
}
static void NativeRichEditorSpanResultListFree(NativeRichEditorSpanResult* src)
static void NativeRichEditorSpanResultListFree(int64_t size, NativeRichEditorSpanResult* src)
{
delete src;
if (!src) {
return;
}
for (int64_t i = 0; i < size; i++) {
if (src[i].textResult.value) {
delete src[i].textResult.value;
}
}
delete[] src;
}
NativeRichEditorSpanResultList NativeRichEditorController::GetSpans(int32_t start, int32_t end)
@ -413,7 +428,9 @@ NativeRichEditorSpanResultList NativeRichEditorController::GetSpans(int32_t star
SelectionInfo selectionInfo = richEditorController->GetSpansInfo(start, end);
const std::list<ResultObject>& spanObjectList = selectionInfo.GetSelection().resultObjects;
if (spanObjectList.size() == 0) {
return result;
}
auto spans = new NativeRichEditorSpanResult[spanObjectList.size()];
size_t idx = 0;
for (const ResultObject& spanObject : spanObjectList) {
@ -454,7 +471,9 @@ void NativeRichEditorController::UpdateParagraphStyle(
{
style.leadingMargin = std::make_optional<NG::LeadingMargin>();
Dimension resWidth(params.margin, static_cast<DimensionUnit>(params.marginUnit));
style.leadingMargin->size = NG::LeadingMarginSize(resWidth, Dimension(0.0, DimensionUnit::PX));
auto widthCalc = CalcDimension(resWidth.ConvertToPx());
auto heightCalc = CalcDimension(0.0);
style.leadingMargin->size = NG::LeadingMarginSize(widthCalc, heightCalc);
break;
}
case MarginType::MARGIN_PLACEHOLDER:
@ -468,7 +487,9 @@ void NativeRichEditorController::UpdateParagraphStyle(
#endif
Dimension width(placeholder.width, static_cast<DimensionUnit>(placeholder.widthUnit));
Dimension height(placeholder.height, static_cast<DimensionUnit>(placeholder.heightUnit));
style.leadingMargin->size = NG::LeadingMarginSize(width, height);
auto widthCalc = CalcDimension(width.ConvertToPx());
auto heightCalc = CalcDimension(height.ConvertToPx());
style.leadingMargin->size = NG::LeadingMarginSize(widthCalc, heightCalc);
break;
}
default:

View File

@ -136,7 +136,7 @@ struct NativeRichEditorSpanResult {
struct NativeRichEditorSpanResultList {
NativeRichEditorSpanResult* array;
int64_t size;
void (*free)(NativeRichEditorSpanResult*);
void (*free)(int64_t, NativeRichEditorSpanResult*);
};
struct NativeRichEditorSelection {

View File

@ -203,6 +203,13 @@ void FfiOHOSAceFrameworkScrollScrollBarWidth(double width, int32_t unit)
ScrollModel::GetInstance()->SetScrollBarWidth(value);
}
void FfiOHOSAceFrameworkScrollNestedScroll(int32_t scrollForward, int32_t scrollBackward)
{
NestedScrollOptions localNestedScrollOptions = {.forward = NestedScrollMode(scrollForward),
.backward = NestedScrollMode(scrollBackward)};
ScrollModel::GetInstance()->SetNestedScroll(localNestedScrollOptions);
}
void FfiOHOSAceFrameworkScrollOnScroll(void (*callback)(CJOffset scrollInfo))
{
ScrollModel::GetInstance()->SetOnScroll(

View File

@ -70,6 +70,7 @@ CJ_EXPORT void FfiOHOSAceFrameworkScrollScrollable(int32_t scrollDirection);
CJ_EXPORT void FfiOHOSAceFrameworkScrollScrollBar(int32_t barState);
CJ_EXPORT void FfiOHOSAceFrameworkScrollScrollBarColor(uint32_t color);
CJ_EXPORT void FfiOHOSAceFrameworkScrollScrollBarWidth(double width, int32_t unit);
CJ_EXPORT void FfiOHOSAceFrameworkScrollNestedScroll(int32_t scrollForward, int32_t scrollBackward);
CJ_EXPORT void FfiOHOSAceFrameworkScrollOnScroll(void (*callback)(CJOffset offset));
CJ_EXPORT void FfiOHOSAceFrameworkScrollOnScrollEdge(void (*callback)(int32_t edge));
CJ_EXPORT void FfiOHOSAceFrameworkScrollOnScrollEnd(void (*callback)());

View File

@ -112,6 +112,18 @@ void FfiOHOSAceFrameworkTextFieldSetPaddings(CJEdge params)
FfiOHOSAceFrameworkViewAbstractSetPaddings(params);
}
void FfiOHOSAceFrameworkTextFieldSetMargin(double value, int32_t unit)
{
FfiOHOSAceFrameworkViewAbstractSetMargin(value, unit);
TextFieldModel::GetInstance()->SetMargin();
}
void FfiOHOSAceFrameworkTextFieldSetMargins(CJEdge params)
{
FfiOHOSAceFrameworkViewAbstractSetMargins(params);
TextFieldModel::GetInstance()->SetMargin();
}
void FfiOHOSAceFrameworkTextFieldSetPlaceholderColor(uint32_t value)
{
TextFieldModel::GetInstance()->SetPlaceholderColor(Color(value));

View File

@ -32,6 +32,8 @@ CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetBorderRadius(double value, uint32_
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetBackgroundColor(uint32_t color);
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetPadding(double value, int32_t unit);
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetPaddings(CJEdge params);
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetMargin(double value, int32_t unit);
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetMargins(CJEdge params);
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetType(int32_t value);
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetPlaceholderColor(uint32_t value);
CJ_EXPORT void FfiOHOSAceFrameworkTextFieldSetPlaceholderFont(

View File

@ -93,4 +93,9 @@ void FfiOHOSAceFrameworkToggleOnChange(void (*callback)(bool isOn))
};
ToggleModel::GetInstance()->OnChange(std::move(onChange));
}
void FfiOHOSAceFrameworkTogglePop()
{
ToggleModel::GetInstance()->Pop();
}
}

View File

@ -32,6 +32,7 @@ CJ_EXPORT void FfiOHOSAceFrameworkTogglePadding(double left, int32_t leftUnit, d
CJ_EXPORT void FfiOHOSAceFrameworkToggleSelectedColor(uint32_t color);
CJ_EXPORT void FfiOHOSAceFrameworkToggleSwitchPointColor(uint32_t color);
CJ_EXPORT void FfiOHOSAceFrameworkToggleOnChange(void (*callback)(bool isOn));
CJ_EXPORT void FfiOHOSAceFrameworkTogglePop();
}
#endif // OHOS_ACE_FRAMEWORK_CJ_TOGGLE_FFI_H

View File

@ -1425,39 +1425,25 @@ void FfiOHOSAceFrameworkViewAbstractExpandSafeArea(uint32_t types, uint32_t edge
ViewAbstractModel::GetInstance()->UpdateSafeAreaExpandOpts(opts);
}
void FfiOHOSAceFrameworkViewAbstractbindSheetParam2(bool isShow, void (*builder)())
{
auto buildFunc = CJLambda::Create(builder);
NG::SheetStyle sheetStyle;
DoubleBindCallback callback = nullptr;
std::function<void()> onAppearCallback;
std::function<void()> onDisappearCallback;
std::function<void()> onWillAppearCallback;
std::function<void()> onWillDisappearCallback;
std::function<void()> shouldDismissFunc;
std::function<void(const int32_t)> onWillDismissCallback;
std::function<void(const float)> onHeightDidChangeCallback;
std::function<void(const float)> onDetentsDidChangeCallback;
std::function<void(const float)> onWidthDidChangeCallback;
std::function<void(const float)> onTypeDidChangeCallback;
std::function<void()> titleBuilderFunction;
std::function<void()> sheetSpringBackFunc;
ViewAbstractModel::GetInstance()->BindSheet(isShow, std::move(callback), std::move(buildFunc),
std::move(titleBuilderFunction), sheetStyle, std::move(onAppearCallback), std::move(onDisappearCallback),
std::move(shouldDismissFunc), std::move(onWillDismissCallback), std::move(onWillAppearCallback),
std::move(onWillDisappearCallback), std::move(onHeightDidChangeCallback), std::move(onDetentsDidChangeCallback),
std::move(onWidthDidChangeCallback), std::move(onTypeDidChangeCallback), std::move(sheetSpringBackFunc));
}
void ParseSheetCallback(CJSheetOptions options, std::function<void()>& onAppear,
std::function<void()>& onDisappear, std::function<void()>& shouldDismiss)
std::function<void()>& onDisappear, std::function<void()>& shouldDismiss, std::function<void()>& onWillAppear,
std::function<void()>& onWillDisappear)
{
onAppear = options.onAppear.hasValue ? CJLambda::Create(options.onAppear.value)
: ([]() -> void {});
onDisappear = options.onDisappear.hasValue ? CJLambda::Create(options.onDisappear.value)
: ([]() -> void {});
shouldDismiss = options.shouldDismiss.hasValue ? CJLambda::Create(options.shouldDismiss.value)
: ([]() -> void {});
if (options.onAppear.hasValue) {
onAppear = CJLambda::Create(options.onAppear.value);
}
if (options.onDisappear.hasValue) {
onDisappear = CJLambda::Create(options.onDisappear.value);
}
if (options.shouldDismiss.hasValue) {
shouldDismiss = CJLambda::Create(options.shouldDismiss.value);
}
if (options.onWillAppear.hasValue) {
onWillAppear = CJLambda::Create(options.onWillAppear.value);
}
if (options.onWillDisappear.hasValue) {
onWillDisappear = CJLambda::Create(options.onWillDisappear.value);
}
}
void ParseSheetDetentHeight(const int args, NG::SheetHeight& detent)
@ -1552,13 +1538,14 @@ void ParseSheetTitle(CJSheetOptions option, NG::SheetStyle& sheetStyle, std::fun
titleBuilderFunction = option.title.hasValue ? CJLambda::Create(option.title.value)
: ([]() -> void {});
}
void FfiOHOSAceFrameworkViewAbstractbindSheetParam3(bool isShow, void (*builder)(), CJSheetOptions option)
void FfiOHOSAceFrameworkViewAbstractbindSheetParam(bool isShow, void (*builder)(), CJSheetOptions option)
{
auto buildFunc = CJLambda::Create(builder);
NG::SheetStyle sheetStyle;
DoubleBindCallback callback = nullptr;
sheetStyle.sheetMode = NG::SheetMode::LARGE;
sheetStyle.showDragBar = true;
sheetStyle.showInPage = false;
std::function<void()> onAppearCallback;
std::function<void()> onDisappearCallback;
std::function<void()> onWillAppearCallback;
@ -1571,14 +1558,16 @@ void FfiOHOSAceFrameworkViewAbstractbindSheetParam3(bool isShow, void (*builder)
std::function<void(const float)> onTypeDidChangeCallback;
std::function<void()> titleBuilderFunction;
std::function<void()> sheetSpringBackFunc;
ParseSheetCallback(option, onAppearCallback, onDisappearCallback, shouldDismissFunc);
ParseSheetCallback(option, onAppearCallback, onWillDisappearCallback, shouldDismissFunc,
onWillAppearCallback, onWillDisappearCallback);
ParseSheetStyle(option, sheetStyle);
ParseSheetTitle(option, sheetStyle, titleBuilderFunction);
ViewAbstractModel::GetInstance()->BindSheet(isShow, std::move(callback), std::move(buildFunc),
std::move(titleBuilderFunction), sheetStyle, std::move(onAppearCallback), std::move(onDisappearCallback),
std::move(shouldDismissFunc), std::move(onWillDismissCallback), std::move(onWillAppearCallback),
std::move(onWillDisappearCallback), std::move(onHeightDidChangeCallback), std::move(onDetentsDidChangeCallback),
std::move(onWidthDidChangeCallback), std::move(onTypeDidChangeCallback), std::move(sheetSpringBackFunc));
std::move(onWillDisappearCallback), std::move(onHeightDidChangeCallback),
std::move(onDetentsDidChangeCallback), std::move(onWidthDidChangeCallback),
std::move(onTypeDidChangeCallback), std::move(sheetSpringBackFunc));
return;
}

View File

@ -238,8 +238,7 @@ CJ_EXPORT void FfiOHOSAceFrameworkViewAbstractSetScaleSingle(float scale);
CJ_EXPORT void FfiOHOSAceFrameworkViewAbstractSetScaleX(float scaleVal);
CJ_EXPORT void FfiOHOSAceFrameworkViewAbstractSetScaleY(float scaleVal);
CJ_EXPORT void FfiOHOSAceFrameworkViewAbstractSetOpacity(double opacity);
CJ_EXPORT void FfiOHOSAceFrameworkViewAbstractbindSheetParam3(bool isShow, void (*builder)(), CJSheetOptions option);
CJ_EXPORT void FfiOHOSAceFrameworkViewAbstractbindSheetParam2(bool isShow, void (*builder)());
CJ_EXPORT void FfiOHOSAceFrameworkViewAbstractbindSheetParam(bool isShow, void (*builder)(), CJSheetOptions option);
struct CJSetRotate {
float dx;

View File

@ -13,10 +13,9 @@
* limitations under the License.
*/
#include "at_manager_impl.h"
#include "application_context.h"
#include "cj_web_ffi.h"
#include "application_context.h"
#include "cj_lambda.h"
#include "webview_controller_impl.h"
@ -28,9 +27,9 @@
#include "bridge/cj_frontend/interfaces/cj_ffi/utils.h"
#include "core/common/container.h"
#include "core/common/container_scope.h"
#include "core/components/web/web_event.h"
#include "core/components_ng/pattern/web/web_model_ng.h"
#include "core/pipeline/pipeline_base.h"
#include "core/components/web/web_event.h"
using namespace OHOS::Ace;
using namespace OHOS::FFI;
@ -46,6 +45,8 @@ struct FfiWebEvent {
namespace OHOS::Ace::Framework {
bool g_cjWebDebuggingAccess = false;
constexpr int32_t PARENT_FIRST_VALUE = 2;
RequestResultCallback g_requestResultcb = nullptr;
class CJWebWindowNewHandler : public Referenced {
public:
@ -111,8 +112,7 @@ public:
return;
}
controller_map_.insert(
std::pair<int32_t, ChildWindowInfo>(handler_->GetId(), { parentNWebId, controller })
);
std::pair<int32_t, ChildWindowInfo>(handler_->GetId(), { parentNWebId, controller }));
}
}
@ -196,11 +196,11 @@ char* MallocCString(const std::string& origin)
return std::char_traits<char>::copy(res, origin.c_str(), len);
}
void RequestPermissionsFromUserWeb(CJWebPermissionRequest &request)
void RequestPermissionsFromUserWeb(CJWebPermissionRequest& request)
{
auto abilityContext = AbilityRuntime::Context::GetApplicationContext();
std::string permission = "ohos.permission.READ_PASTEBOARD";
char *cPermission = MallocCString(permission);
char* cPermission = MallocCString(permission);
auto callBack = [&request](RetDataCPermissionRequestResult infoRef) -> void {
if (infoRef.code == 0) {
@ -210,16 +210,21 @@ void RequestPermissionsFromUserWeb(CJWebPermissionRequest &request)
}
};
OHOS::CJSystemapi::AtManagerImpl::RequestPermissionsFromUser(
abilityContext.get(),
CArrString{.head = &cPermission, .size = 1},
callBack);
std::function<void(RetDataCPermissionRequestResult)> func = callBack;
g_requestResultcb(abilityContext.get(), CArrString { .head = &cPermission, .size = 1 }, &func);
free(cPermission);
}
}
} // namespace OHOS::Ace::Framework
std::unordered_map<int32_t, CJWebWindowNewHandler::ChildWindowInfo> CJWebWindowNewHandler::controller_map_;
extern "C" {
void FfiOHOSAceFrameworkWebSetCallback(RequestResultCallback cb)
{
if (g_requestResultcb == nullptr) {
g_requestResultcb = cb;
}
}
void FfiOHOSAceFrameworkWebCreate(const char* src, int64_t controllerId, int32_t type, bool mode)
{
std::string webSrc = src;
@ -235,17 +240,12 @@ void FfiOHOSAceFrameworkWebCreate(const char* src, int64_t controllerId, int32_t
auto controller = FFIData::GetData<WebviewControllerImpl>(controllerId);
if (controller) {
auto setIdCallback = [controller](int32_t webId) {
controller->SetWebId(webId);
};
auto setIdCallback = [controller](int32_t webId) { controller->SetWebId(webId); };
std::function<void(const std::string&)> setHapPathCallback = nullptr;
setHapPathCallback = [controller](const std::string& hapPath) {
controller->InnerSetHapPath(hapPath);
};
setHapPathCallback = [controller](const std::string& hapPath) { controller->InnerSetHapPath(hapPath); };
std::function<void(const std::shared_ptr<BaseEventInfo>&)> requestPermissionsFromUserCallback = nullptr;
requestPermissionsFromUserCallback = [controller](
const std::shared_ptr<BaseEventInfo>& info) {
requestPermissionsFromUserCallback = [controller](const std::shared_ptr<BaseEventInfo>& info) {
auto* eventInfo = TypeInfoHelper::DynamicCast<WebPermissionRequestEvent>(info.get());
auto permissionObj = OHOS::Ace::Framework::CJWebPermissionRequest();
permissionObj.SetEvent(*eventInfo);
@ -254,9 +254,8 @@ void FfiOHOSAceFrameworkWebCreate(const char* src, int64_t controllerId, int32_t
int32_t parentNWebId = -1;
bool isPopup = CJWebWindowNewHandler::ExistController(controller, parentNWebId);
WebModel::GetInstance()->Create(
dstSrc.value(), std::move(setIdCallback),
std::move(setHapPathCallback), parentNWebId, isPopup, renderMode, mode);
WebModel::GetInstance()->Create(dstSrc.value(), std::move(setIdCallback), std::move(setHapPathCallback),
parentNWebId, isPopup, renderMode, mode);
WebModel::GetInstance()->SetPermissionClipboard(std::move(requestPermissionsFromUserCallback));
if (!controller->customeSchemeCmdLine_.empty()) {
WebModel::GetInstance()->SetCustomScheme(controller->customeSchemeCmdLine_);
@ -350,6 +349,40 @@ void FfiOHOSAceFrameworkWebGeolocationAccessEnabled(bool isGeolocationAccessEnab
WebModel::GetInstance()->SetGeolocationAccessEnabled(isGeolocationAccessEnabled);
}
void FfiOHOSAceFrameworkWebVerticalScrollBarAccessEnabled(bool isVerticalScrollBarAccess)
{
WebModel::GetInstance()->SetVerticalScrollBarAccessEnabled(isVerticalScrollBarAccess);
}
NestedScrollMode GetNestedScrollModeValue(int32_t value)
{
auto ret = NestedScrollMode::SELF_ONLY;
switch (value) {
case 0:
ret = NestedScrollMode::SELF_ONLY;
break;
case 1:
ret = NestedScrollMode::SELF_FIRST;
break;
case PARENT_FIRST_VALUE:
ret = NestedScrollMode::PARENT_FIRST;
break;
default:
ret = NestedScrollMode::PARALLEL;
break;
}
return ret;
}
void FfiOHOSAceFrameworkNestedScroll(int32_t nestedScrollNum, int32_t scrollBackwardNum)
{
NestedScrollOptions nestedOpt = {
.forward = GetNestedScrollModeValue(nestedScrollNum),
.backward = GetNestedScrollModeValue(scrollBackwardNum),
};
WebModel::GetInstance()->SetNestedScroll(nestedOpt);
}
void FfiOHOSAceFrameworkWebUserAgent(const std::string& userAgent)
{
WebModel::GetInstance()->SetUserAgent(userAgent);
@ -392,6 +425,68 @@ void FfiOHOSAceFrameworkWebOnPageStart(void (*callback)(const char* url))
WebModel::GetInstance()->SetOnPageStart(std::move(onStart));
}
bool WebRequestHeadersToMapToCFFIArray(const RefPtr<WebRequest>& webRequest, MapToCFFIArray& res)
{
std::map<std::string, std::string> header = webRequest->GetHeaders();
auto key = (const char**)malloc(sizeof(const char*) * header.size());
auto value = (const char**)malloc(sizeof(const char*) * header.size());
if (key == NULL || value == NULL) {
if (key != NULL) {
free(key);
}
if (value != NULL) {
free(value);
}
LOGE("FfiOHOSAceFrameworkGetHeaders fail, malloc fail");
return false;
}
size_t i = 0;
res.size = header.size();
res.key = key;
res.value = value;
for (auto it = header.begin(); it != header.end(); ++it, ++i) {
res.key[i] = it->first.c_str();
res.value[i] = it->second.c_str();
}
return true;
}
void MapToCFFIArrayToFreeMemory(MapToCFFIArray& mapToCFFIArray)
{
for (size_t i = 0; i < mapToCFFIArray.size; ++i) {
free(&mapToCFFIArray.key[i]);
free(&mapToCFFIArray.value[i]);
}
free(mapToCFFIArray.key);
free(mapToCFFIArray.value);
}
void FfiOHOSAceFrameworkWebOnLoadIntercept(bool (*callback)(FfiWebResourceRequest event))
{
auto instanceId = Container::CurrentId();
auto onLoadIntercept = [func = CJLambda::Create(callback), instanceId](const BaseEventInfo* info) {
ContainerScope scope(instanceId);
FfiWebResourceRequest cjWebResourceRequest {};
auto* eventInfo = TypeInfoHelper::DynamicCast<LoadInterceptEvent>(info);
auto request = eventInfo->GetRequest();
MapToCFFIArray mapToCFFIArray;
auto wirteSuccess = WebRequestHeadersToMapToCFFIArray(request, mapToCFFIArray);
if (!wirteSuccess) {
return false;
}
cjWebResourceRequest.url = request->GetUrl().c_str();
cjWebResourceRequest.isMainFrame = request->IsMainFrame();
cjWebResourceRequest.isRedirect = request->IsRedirect();
cjWebResourceRequest.hasGesture = request->HasGesture();
cjWebResourceRequest.method = request->GetMethod().c_str();
cjWebResourceRequest.mapToCFFIArray = &mapToCFFIArray;
auto res = func(cjWebResourceRequest);
MapToCFFIArrayToFreeMemory(mapToCFFIArray);
return res;
};
WebModel::GetInstance()->SetOnLoadIntercept(std::move(onLoadIntercept));
}
void FfiOHOSAceFrameworkWebOnPageFinish(void (*callback)(const char* url))
{
auto instanceId = Container::CurrentId();
@ -412,10 +507,8 @@ CJ_EXPORT void FfiOHOSAceFrameworkWebJavaScriptProxy(
auto& funcs = *reinterpret_cast<std::vector<int64_t>*>(funcList);
std::vector<std::function<char*(const char*)>> cFuncs;
for (int64_t i = 0; i < static_cast<int64_t>(funcs.size()); i++) {
auto cFunc = reinterpret_cast<char*(*)(const char*)>(funcs[i]);
auto wrapper = [lambda = CJLambda::Create(cFunc)](const char* str) -> char* {
return lambda(str);
};
auto cFunc = reinterpret_cast<char* (*)(const char*)>(funcs[i]);
auto wrapper = [lambda = CJLambda::Create(cFunc)](const char* str) -> char* { return lambda(str); };
cFuncs.push_back(wrapper);
}
std::string cName = std::string(name);

View File

@ -16,16 +16,46 @@
#ifndef OHOS_ACE_FRAMEWORK_CJ_WEB_H
#define OHOS_ACE_FRAMEWORK_CJ_WEB_H
#include <cstdint>
#include <map>
#include <string>
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
#include "core/components/web/web_component.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_container_base_ffi.h"
#include "webview_controller_impl.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_collection_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_container_base_ffi.h"
#include "core/components/web/web_component.h"
struct FfiWebEvent;
extern "C" {
struct CPermissionRequestResult {
CArrString permissions;
CArrI32 authResults;
};
struct RetDataCPermissionRequestResult {
int32_t code;
CPermissionRequestResult data;
};
struct MapToCFFIArray {
size_t size;
const char** key;
const char** value;
};
struct FfiWebResourceRequest {
const char* url;
bool isMainFrame;
bool isRedirect;
bool hasGesture;
const char* method;
MapToCFFIArray* mapToCFFIArray;
};
typedef void (*RequestResultCallback)(void*, CArrString, void*);
CJ_EXPORT void FfiOHOSAceFrameworkWebHandleCancel(void* result);
CJ_EXPORT void FfiOHOSAceFrameworkWebHandleConfirm(void* result);
CJ_EXPORT void FfiOHOSAceFrameworkWebHandlePromptConfirm(void* result, const char* message);
@ -39,13 +69,16 @@ CJ_EXPORT void FfiOHOSAceFrameworkWebOnlineImageAccessEnabled(bool isImageAccess
CJ_EXPORT void FfiOHOSAceFrameworkWebMixedMode(int32_t mixedModeNum);
CJ_EXPORT void FfiOHOSAceFrameworkWebZoomAccessEnabled(bool isZoomAccessEnabled);
CJ_EXPORT void FfiOHOSAceFrameworkWebGeolocationAccessEnabled(bool isGeolocationAccessEnabled);
CJ_EXPORT void FfiOHOSAceFrameworkWebVerticalScrollBarAccessEnabled(bool isVerticalScrollBarAccess);
CJ_EXPORT void FfiOHOSAceFrameworkNestedScroll(int32_t nestedScrollNum, int32_t scrollBackwardNum);
CJ_EXPORT void FfiOHOSAceFrameworkWebUserAgent(const std::string& userAgent);
CJ_EXPORT void FfiOHOSAceFrameworkWebOnAlert(bool (*callback)(FfiWebEvent event));
CJ_EXPORT void FfiOHOSAceFrameworkWebOnPageStart(void (*callback)(const char* url));
CJ_EXPORT void FfiOHOSAceFrameworkWebOnPageFinish(void (*callback)(const char* url));
CJ_EXPORT void FfiOHOSAceFrameworkWebOnLoadIntercept(bool (*callback)(FfiWebResourceRequest event));
CJ_EXPORT void FfiOHOSAceFrameworkWebJavaScriptProxy(
VectorInt64Handle funcList, const char* name, VectorStringHandle methodList, int64_t controllerId);
CJ_EXPORT void FfiOHOSAceFrameworkWebSetCallback(RequestResultCallback cb);
};
#endif // OHOS_ACE_FRAMEWORK_CJ_WEB_H

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2024 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.
*/
#include "cj_font_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/utils.h"
using namespace OHOS::Ace;
using namespace OHOS::Ace::Framework;
extern "C" {
void FfiFontManagerRegisterFont(const char* familyName, const char* familySrc)
{
auto frontend = AceType::DynamicCast<CJFrontendAbstract>(Utils::GetCurrentFrontend());
if (!frontend) {
LOGE("Can not get frontend.");
return;
}
frontend->RegisterFont(familyName, familySrc);
}
VectorStringHandle FfiFontManagerGetSystemFontList()
{
auto frontend = AceType::DynamicCast<CJFrontendAbstract>(Utils::GetCurrentFrontend());
if (!frontend) {
LOGE("Can not get frontend.");
return nullptr;
}
return frontend->GetSystemFontList();
}
NativeOptionFontInfo FfiFontManagerGetFontByName(const char* fontName)
{
auto frontend = AceType::DynamicCast<CJFrontendAbstract>(Utils::GetCurrentFrontend());
if (!frontend) {
LOGE("Can not get frontend.");
return NativeOptionFontInfo { .hasValue = false, .info = nullptr };
}
return frontend->GetSystemFont(fontName);
}
}

View File

@ -0,0 +1,29 @@
/*
* 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.
*/
#ifndef OHOS_ACE_FRAMEWORK_CJ_FONT_MANAGER
#define OHOS_ACE_FRAMEWORK_CJ_FONT_MANAGER
#include "bridge/cj_frontend/frontend/cj_frontend_abstract.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_collection_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_macro.h"
extern "C" {
CJ_EXPORT void FfiFontManagerRegisterFont(const char* familyName, const char* familySrc);
CJ_EXPORT VectorStringHandle FfiFontManagerGetSystemFontList();
CJ_EXPORT NativeOptionFontInfo FfiFontManagerGetFontByName(const char* fontName);
}
#endif // OHOS_ACE_FRAMEWORK_CJ_FONT_MANAGER

View File

@ -28,9 +28,19 @@ CJ_EXPORT int FfiOHOSAceFrameworkWebOnlineImageAccessEnabled = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebMixedMode = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebZoomAccessEnabled = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebGeolocationAccessEnabled = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebVerticalScrollBarAccessEnabled = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebUserAgent = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebOnAlert = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebOnPageStart = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebOnPageFinish = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebJavaScriptProxy = 0;
}
CJ_EXPORT int FfiOHOSAceFrameworkNestedScroll = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebOnLoadIntercept = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebGetHeaders = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebGetUrl = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebIsRedirect = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebIsMainFrame = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebHasGesture = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebGetMethod = 0;
CJ_EXPORT int FfiOHOSAceFrameworkWebSetCallback = 0;
}

View File

@ -22,7 +22,7 @@
namespace OHOS::Ace::NG {
class ACE_EXPORT CanvasRenderingContext2DModelNG : public OHOS::Ace::CanvasRenderingContext2DModel {
class ACE_FORCE_EXPORT CanvasRenderingContext2DModelNG : public OHOS::Ace::CanvasRenderingContext2DModel {
DECLARE_ACE_TYPE(CanvasRenderingContext2DModelNG, CanvasRenderingContext2DModel)
public:

View File

@ -70,7 +70,7 @@ public:
{
completeReloadFunc_ = std::move(func);
}
void FlushReload();
ACE_FORCE_EXPORT void FlushReload();
void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override
{

View File

@ -23,7 +23,7 @@
namespace OHOS::Ace {
class CanvasModel {
public:
static CanvasModel* GetInstance();
ACE_FORCE_EXPORT static CanvasModel* GetInstance();
static CanvasModel* GetInstanceNG();
virtual ~CanvasModel() = default;

View File

@ -187,8 +187,8 @@ void PagePattern::OnAttachToMainTree()
auto delegate = EngineHelper::GetCurrentDelegate();
if (delegate) {
index = delegate->GetStackSize();
GetPageInfo()->SetPageIndex(index);
}
GetPageInfo()->SetPageIndex(index);
state_ = RouterPageState::ABOUT_TO_APPEAR;
UIObserverHandler::GetInstance().NotifyRouterPageStateChange(GetPageInfo(), state_);
}