mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-21 09:55:23 -04:00
新模型中适配designWidth、autoDesignWidth
Change-Id: Icd1b616e5daee08b7eda010ec72a9e3fddf11041 Signed-off-by: zhangxiao72 <zhangxiao72@huawei.com>
This commit is contained in:
@@ -140,7 +140,11 @@ RefPtr<AcePage> CardFrontend::GetPage(int32_t pageId) const
|
||||
WindowConfig& CardFrontend::GetWindowConfig()
|
||||
{
|
||||
ParseManifest();
|
||||
return manifestParser_->GetWindowConfig();
|
||||
if (GetFormSrc().empty()) {
|
||||
return manifestParser_->GetWindowConfig();
|
||||
} else {
|
||||
return GetCardWindowConfig();
|
||||
}
|
||||
}
|
||||
|
||||
void CardFrontend::LoadPage(const std::string& urlPath, const std::string& params)
|
||||
|
||||
@@ -159,6 +159,16 @@ public:
|
||||
formSrc_ = formSrc;
|
||||
}
|
||||
|
||||
WindowConfig& GetCardWindowConfig()
|
||||
{
|
||||
return cardWindowConfig_;
|
||||
}
|
||||
|
||||
void SetCardWindowConfig(WindowConfig cardWindowConfig)
|
||||
{
|
||||
cardWindowConfig_ = cardWindowConfig;
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdatePageData(const std::string& dataList);
|
||||
void LoadPage(const std::string& urlPath, const std::string& params);
|
||||
@@ -187,6 +197,7 @@ private:
|
||||
Framework::PageIdPool pageIdPool_;
|
||||
RefPtr<Framework::JsCardParser> parseJsCard_;
|
||||
std::string formSrc_;
|
||||
WindowConfig cardWindowConfig_;
|
||||
};
|
||||
|
||||
class CardEventHandler : public AceEventHandler {
|
||||
|
||||
@@ -240,18 +240,20 @@ void FormElement::Prepare(const WeakPtr<Element>& parent)
|
||||
int32_t instanceID = context->GetInstanceId();
|
||||
formManagerBridge_->AddFormAcquireCallback(
|
||||
[weak = WeakClaim(this), instanceID](int64_t id, std::string path, std::string module, std::string data,
|
||||
std::map<std::string, std::pair<int, int32_t>> imageDataMap, std::string formSrc) {
|
||||
std::map<std::string, std::pair<int, int32_t>> imageDataMap, AppExecFwk::FormJsInfo formJsInfo) {
|
||||
ContainerScope scope(instanceID);
|
||||
auto element = weak.Upgrade();
|
||||
auto uiTaskExecutor = SingleTaskExecutor::Make(
|
||||
element->GetContext().Upgrade()->GetTaskExecutor(), TaskExecutor::TaskType::UI);
|
||||
uiTaskExecutor.PostTask([id, path, module, data, imageDataMap, formSrc, weak, instanceID] {
|
||||
uiTaskExecutor.PostTask([id, path, module, data, imageDataMap, formJsInfo, weak, instanceID] {
|
||||
ContainerScope scope(instanceID);
|
||||
auto form = weak.Upgrade();
|
||||
if (form) {
|
||||
auto container = form->GetSubContainer();
|
||||
if (container) {
|
||||
container->RunCard(id, path, module, data, imageDataMap, formSrc);
|
||||
container->SetWindowConfig(
|
||||
{ formJsInfo.formWindow.designWidth, formJsInfo.formWindow.autoDesignWidth });
|
||||
container->RunCard(id, path, module, data, imageDataMap, formJsInfo.formSrc);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -373,7 +373,7 @@ void FormManagerDelegate::ProcessFormUpdate(const AppExecFwk::FormJsInfo &formJs
|
||||
}
|
||||
hasCreated_ = true;
|
||||
onFormAcquiredCallback_(runningCardId_, formJsInfo.jsFormCodePath + "/", formJsInfo.formName,
|
||||
formJsInfo.formData, formJsInfo.imageDataMap, formJsInfo.formSrc);
|
||||
formJsInfo.formData, formJsInfo.imageDataMap, formJsInfo);
|
||||
} else {
|
||||
if (formJsInfo.formData.empty()) {
|
||||
LOGE("update form data success, but data is empty!!!");
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
using OnFormUpdateCallbackForJava = std::function<void(int64_t, const std::string&)>;
|
||||
using OnFormAcquiredCallback
|
||||
= std::function<void(int64_t, const std::string&, const std::string&,
|
||||
const std::string&, const std::map<std::string, std::pair<int, int32_t>>&, const std::string&)>;
|
||||
const std::string&, const std::map<std::string, std::pair<int, int32_t>>&, const AppExecFwk::FormJsInfo&)>;
|
||||
using OnFormUpdateCallback = std::function<void(int64_t, const std::string&,
|
||||
const std::map<std::string, std::pair<int, int32_t>>&)>;
|
||||
using OnFormErrorCallback = std::function<void(const std::string&, const std::string&)>;
|
||||
|
||||
@@ -161,6 +161,7 @@ void SubContainer::RunCard(const int64_t id, const std::string path, const std::
|
||||
}
|
||||
}
|
||||
frontend_->SetFormSrc(formSrc);
|
||||
frontend_->SetCardWindowConfig(GetWindowConfig());
|
||||
auto&& window = std::make_unique<FormWindow>(outSidePipelineContext_);
|
||||
|
||||
pipelineContext_ = AceType::MakeRefPtr<PipelineContext>(
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "ashmem.h"
|
||||
|
||||
#include "base/thread/task_executor.h"
|
||||
#include "core/common/frontend.h"
|
||||
#include "frameworks/bridge/card_frontend/card_frontend.h"
|
||||
#include "frameworks/core/pipeline/pipeline_context.h"
|
||||
|
||||
@@ -93,6 +94,16 @@ public:
|
||||
}
|
||||
bool Dump(const std::vector<std::string>& params);
|
||||
|
||||
WindowConfig GetWindowConfig() const
|
||||
{
|
||||
return cardWindowConfig_;
|
||||
}
|
||||
|
||||
void SetWindowConfig(const WindowConfig cardWindowConfig)
|
||||
{
|
||||
cardWindowConfig_ = cardWindowConfig;
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<CardFrontend> frontend_;
|
||||
RefPtr<TaskExecutor> taskExecutor_;
|
||||
@@ -107,6 +118,7 @@ private:
|
||||
RefPtr<Component> formComponent_;
|
||||
WeakPtr<Element> formElement_;
|
||||
OnFormAcquiredCallback onFormAcquiredCallback_;
|
||||
WindowConfig cardWindowConfig_;
|
||||
|
||||
double surfaceWidth_ = 1.0f;
|
||||
double surfaceHeight_ = 1.0f;
|
||||
|
||||
Reference in New Issue
Block a user