已合并
arkweb 拖入适配多entry拖出新增Tag #60201
zhufenghao创建于 2025年4月7日
arkweb 拖入适配多entry拖出新增Tag #60201
已合并
从refs/pull/60201/head合入到OpenHarmony-5.0.3-Release
共 8 个文件变更+217-16
| @@ -452,4 +452,150 @@ std::vector<uint8_t> UdmfClientImpl::GetSpanStringRecord(const RefPtr<UnifiedDat | |||
| 452 | } | 452 | } |
| 453 | return arr; | 453 | return arr; |
| 454 | } | 454 | } |
| 455 | + | ||
| 456 | +void UdmfClientImpl::SetTagProperty(const RefPtr<UnifiedData>& unifiedData, const std::string& tag) | ||
| 457 | +{ | ||
| 458 | + auto properties = std::make_shared<UDMF::UnifiedDataProperties>(); | ||
| 459 | + properties->tag = tag; | ||
| 460 | + auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData); | ||
| 461 | + CHECK_NULL_VOID(udData); | ||
| 462 | + CHECK_NULL_VOID(udData->GetUnifiedData()); | ||
| 463 | + udData->GetUnifiedData()->SetProperties(properties); | ||
| 464 | +} | ||
| 465 | + | ||
| 466 | +std::string UdmfClientImpl::GetPlainTextEntry(const RefPtr<UnifiedData>& unifiedData) | ||
| 467 | +{ | ||
| 468 | + auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData); | ||
| 469 | + CHECK_NULL_RETURN(udData, std::string()); | ||
| 470 | + CHECK_NULL_RETURN(udData->GetUnifiedData(), std::string()); | ||
| 471 | + auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::PLAIN_TEXT); | ||
| 472 | + CHECK_NULL_RETURN(udData->GetUnifiedData()->HasType(utdId), std::string()); | ||
| 473 | + std::string plainTextSum; | ||
| 474 | + auto records = udData->GetUnifiedData()->GetRecords(); | ||
| 475 | + for (const auto& record : records) { | ||
| 476 | + std::string plainText; | ||
| 477 | + auto value = record->GetEntry(utdId); | ||
| 478 | + if (std::holds_alternative<std::shared_ptr<UDMF::Object>>(value)) { | ||
| 479 | + auto object = std::get<std::shared_ptr<UDMF::Object>>(value); | ||
| 480 | + object->GetValue(UDMF::CONTENT, plainText); | ||
| 481 | + } else if (std::holds_alternative<std::string>(value)) { | ||
| 482 | + plainText = std::get<std::string>(value); | ||
| 483 | + } | ||
| 484 | + plainTextSum += plainText; | ||
| 485 | + } | ||
| 486 | + | ||
| 487 | + if (plainTextSum.empty()) { | ||
| 488 | + std::vector<std::string> plains = GetPlainTextRecords(unifiedData); | ||
| 489 | + if (!plains.empty()) { | ||
| 490 | + plainTextSum = plains[0]; | ||
| 491 | + } | ||
| 492 | + } | ||
| 493 | + return plainTextSum; | ||
| 494 | +} | ||
| 495 | + | ||
| 496 | +void UdmfClientImpl::GetHtmlEntry( | ||
| 497 | + const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) | ||
| 498 | +{ | ||
| 499 | + CHECK_NULL_VOID(htmlContent.empty() && plainContent.empty()); | ||
| 500 | + auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData); | ||
| 501 | + CHECK_NULL_VOID(udData); | ||
| 502 | + CHECK_NULL_VOID(udData->GetUnifiedData()); | ||
| 503 | + auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::HTML); | ||
| 504 | + CHECK_NULL_VOID(udData->GetUnifiedData()->HasType(utdId)); | ||
| 505 | + auto records = udData->GetUnifiedData()->GetRecords(); | ||
| 506 | + for (auto record : records) { | ||
| 507 | + std::string htmlText; | ||
| 508 | + std::string plainText; | ||
| 509 | + auto value = record->GetEntry(utdId); | ||
| 510 | + if (std::holds_alternative<std::shared_ptr<UDMF::Object>>(value)) { | ||
| 511 | + auto object = std::get<std::shared_ptr<UDMF::Object>>(value); | ||
| 512 | + object->GetValue(UDMF::HTML_CONTENT, htmlText); | ||
| 513 | + object->GetValue(UDMF::PLAIN_CONTENT, plainText); | ||
| 514 | + } | ||
| 515 | + htmlContent += htmlText; | ||
| 516 | + plainContent += plainText; | ||
| 517 | + } | ||
| 518 | + | ||
| 519 | + if (htmlContent.empty() && plainContent.empty()) { | ||
| 520 | + GetHtmlRecord(unifiedData, htmlContent, plainContent); | ||
| 521 | + } | ||
| 522 | +} | ||
| 523 | + | ||
| 524 | +void UdmfClientImpl::GetLinkEntry(const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description) | ||
| 525 | +{ | ||
| 526 | + CHECK_NULL_VOID(url.empty() && description.empty()); | ||
| 527 | + auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData); | ||
| 528 | + CHECK_NULL_VOID(udData); | ||
| 529 | + CHECK_NULL_VOID(udData->GetUnifiedData()); | ||
| 530 | + auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::HYPERLINK); | ||
| 531 | + CHECK_NULL_VOID(udData->GetUnifiedData()->HasType(utdId)); | ||
| 532 | + auto records = udData->GetUnifiedData()->GetRecords(); | ||
| 533 | + for (auto record : records) { | ||
| 534 | + std::string currentUrl; | ||
| 535 | + std::string currentDes; | ||
| 536 | + auto value = record->GetEntry(utdId); | ||
| 537 | + if (std::holds_alternative<std::shared_ptr<UDMF::Object>>(value)) { | ||
| 538 | + auto object = std::get<std::shared_ptr<UDMF::Object>>(value); | ||
| 539 | + object->GetValue(UDMF::URL, currentUrl); | ||
| 540 | + object->GetValue(UDMF::DESCRIPTION, currentDes); | ||
| 541 | + } | ||
| 542 | + url += currentUrl; | ||
| 543 | + description += currentDes; | ||
| 544 | + } | ||
| 545 | + | ||
| 546 | + if (url.empty() && description.empty()) { | ||
| 547 | + GetLinkRecord(unifiedData, url, description); | ||
| 548 | + } | ||
| 549 | +} | ||
| 550 | + | ||
| 551 | +bool UdmfClientImpl::GetFileUriEntry(const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri) | ||
| 552 | +{ | ||
| 553 | + CHECK_NULL_RETURN(uri.empty(), false); | ||
| 554 | + auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData); | ||
| 555 | + CHECK_NULL_RETURN(udData, false); | ||
| 556 | + CHECK_NULL_RETURN(udData->GetUnifiedData(), false); | ||
| 557 | + auto records = udData->GetUnifiedData()->GetRecords(); | ||
| 558 | + auto typeList = { UDMF::UDType::IMAGE, UDMF::UDType::AUDIO, UDMF::UDType::VIDEO, UDMF::UDType::FILE, | ||
| 559 | + UDMF::UDType::FILE_URI }; | ||
| 560 | + for (auto record : records) { | ||
| 561 | + std::string currentUri; | ||
| 562 | + for (auto type : typeList) { | ||
| 563 | + auto value = record->GetEntry(UDMF::UtdUtils::GetUtdIdFromUtdEnum(type)); | ||
| 564 | + if (std::holds_alternative<std::shared_ptr<UDMF::Object>>(value)) { | ||
| 565 | + auto object = std::get<std::shared_ptr<UDMF::Object>>(value); | ||
| 566 | + std::string currentEntryUri; | ||
| 567 | + object->GetValue(UDMF::ORI_URI, currentEntryUri); | ||
| 568 | + uri.emplace_back(currentEntryUri); | ||
| 569 | + } | ||
| 570 | + } | ||
| 571 | + } | ||
| 572 | + | ||
| 573 | + if (uri.empty()) { | ||
| 574 | + GetFileUriRecord(unifiedData, uri); | ||
| 575 | + } | ||
| 576 | + return true; | ||
| 577 | +} | ||
| 578 | + | ||
| 579 | +std::vector<uint8_t> UdmfClientImpl::GetSpanStringEntry(const RefPtr<UnifiedData>& unifiedData) | ||
| 580 | +{ | ||
| 581 | + std::vector<uint8_t> arr; | ||
| 582 | + auto udData = AceType::DynamicCast<UnifiedDataImpl>(unifiedData); | ||
| 583 | + CHECK_NULL_RETURN(udData, arr); | ||
| 584 | + CHECK_NULL_RETURN(udData->GetUnifiedData(), arr); | ||
| 585 | + auto utdId = UDMF::UtdUtils::GetUtdIdFromUtdEnum(UDMF::APPLICATION_DEFINED_RECORD); | ||
| 586 | + CHECK_NULL_RETURN(udData->GetUnifiedData()->HasType(utdId), GetSpanStringRecord(unifiedData)); | ||
| 587 | + auto records = udData->GetUnifiedData()->GetRecords(); | ||
| 588 | + for (auto record : records) { | ||
| 589 | + auto value = record->GetEntry(utdId); | ||
| 590 | + if (std::holds_alternative<std::shared_ptr<UDMF::Object>>(value)) { | ||
| 591 | + auto object = std::get<std::shared_ptr<UDMF::Object>>(value); | ||
| 592 | + UDMF::ApplicationDefinedRecord* app = reinterpret_cast<UDMF::ApplicationDefinedRecord*>(object.get()); | ||
| 593 | + if (app && app->GetApplicationDefinedType() == "OPENHARMONY_STYLED_STRING_UDMF") { | ||
| 594 | + arr = app->GetRawData(); | ||
| 595 | + return arr; | ||
| 596 | + } | ||
| 597 | + } | ||
| 598 | + } | ||
| 599 | + return GetSpanStringRecord(unifiedData); | ||
| 600 | +} | ||
| 455 | } // namespace OHOS::Ace | 601 | } // namespace OHOS::Ace |
| @@ -64,6 +64,14 @@ public: | |||
| 64 | std::vector<uint8_t> GetSpanStringRecord(const RefPtr<UnifiedData>& unifiedData) override; | 64 | std::vector<uint8_t> GetSpanStringRecord(const RefPtr<UnifiedData>& unifiedData) override; |
| 65 | int32_t StartAsyncDataRetrieval(napi_env env, napi_value napiValue, const std::string& key) override; | 65 | int32_t StartAsyncDataRetrieval(napi_env env, napi_value napiValue, const std::string& key) override; |
| 66 | int32_t Cancel(const std::string& key) override; | 66 | int32_t Cancel(const std::string& key) override; |
| 67 | + | ||
| 68 | + void SetTagProperty(const RefPtr<UnifiedData>& unifiedData, const std::string& tag) override; | ||
| 69 | + std::string GetPlainTextEntry(const RefPtr<UnifiedData>& unifiedData) override; | ||
| 70 | + void GetHtmlEntry( | ||
| 71 | + const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) override; | ||
| 72 | + void GetLinkEntry(const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description) override; | ||
| 73 | + bool GetFileUriEntry(const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri) override; | ||
| 74 | + std::vector<uint8_t> GetSpanStringEntry(const RefPtr<UnifiedData>& unifiedData) override; | ||
| 67 | }; | 75 | }; |
| 68 | 76 | ||
| 69 | class UnifiedDataImpl : public UnifiedData { | 77 | class UnifiedDataImpl : public UnifiedData { |
| @@ -166,4 +166,26 @@ int32_t UdmfClientImpl::Cancel(const std::string& key) | |||
| 166 | return -1; | 166 | return -1; |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | +void UdmfClientImpl::SetTagProperty(const RefPtr<UnifiedData>& unifiedData, const std::string& tag) {} | ||
| 170 | + | ||
| 171 | +std::string UdmfClientImpl::GetPlainTextEntry(const RefPtr<UnifiedData>& unifiedData) | ||
| 172 | +{ | ||
| 173 | + return ""; | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +void UdmfClientImpl::GetHtmlEntry( | ||
| 177 | + const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) | ||
| 178 | +{} | ||
| 179 | + | ||
| 180 | +void UdmfClientImpl::GetLinkEntry(const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description) {} | ||
| 181 | + | ||
| 182 | +bool UdmfClientImpl::GetFileUriEntry(const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri) | ||
| 183 | +{ | ||
| 184 | + return false; | ||
| 185 | +} | ||
| 186 | + | ||
| 187 | +std::vector<uint8_t> UdmfClientImpl::GetSpanStringEntry(const RefPtr<UnifiedData>& unifiedData) | ||
| 188 | +{ | ||
| 189 | + return {}; | ||
| 190 | +} | ||
| 169 | } // namespace OHOS::Ace | 191 | } // namespace OHOS::Ace |
| @@ -61,6 +61,14 @@ public: | |||
| 61 | std::vector<uint8_t> GetSpanStringRecord(const RefPtr<UnifiedData>& unifiedData) override; | 61 | std::vector<uint8_t> GetSpanStringRecord(const RefPtr<UnifiedData>& unifiedData) override; |
| 62 | int32_t StartAsyncDataRetrieval(napi_env env, napi_value napiValue, const std::string& key) override; | 62 | int32_t StartAsyncDataRetrieval(napi_env env, napi_value napiValue, const std::string& key) override; |
| 63 | int32_t Cancel(const std::string& key) override; | 63 | int32_t Cancel(const std::string& key) override; |
| 64 | + | ||
| 65 | + void SetTagProperty(const RefPtr<UnifiedData>& unifiedData, const std::string& tag) override; | ||
| 66 | + std::string GetPlainTextEntry(const RefPtr<UnifiedData>& unifiedData) override; | ||
| 67 | + void GetHtmlEntry( | ||
| 68 | + const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) override; | ||
| 69 | + void GetLinkEntry(const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description) override; | ||
| 70 | + bool GetFileUriEntry(const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri) override; | ||
| 71 | + std::vector<uint8_t> GetSpanStringEntry(const RefPtr<UnifiedData>& unifiedData) override; | ||
| 64 | }; | 72 | }; |
| 65 | 73 | ||
| 66 | class UnifiedDataImpl : public UnifiedData { | 74 | class UnifiedDataImpl : public UnifiedData { |
| @@ -73,6 +73,14 @@ public: | |||
| 73 | virtual std::vector<uint8_t> GetSpanStringRecord(const RefPtr<UnifiedData>& unifiedData) = 0; | 73 | virtual std::vector<uint8_t> GetSpanStringRecord(const RefPtr<UnifiedData>& unifiedData) = 0; |
| 74 | virtual int32_t StartAsyncDataRetrieval(napi_env env, napi_value napiValue, const std::string& key) = 0; | 74 | virtual int32_t StartAsyncDataRetrieval(napi_env env, napi_value napiValue, const std::string& key) = 0; |
| 75 | virtual int32_t Cancel(const std::string& key) = 0; | 75 | virtual int32_t Cancel(const std::string& key) = 0; |
| 76 | + | ||
| 77 | + virtual void SetTagProperty(const RefPtr<UnifiedData>& unifiedData, const std::string& tag) = 0; | ||
| 78 | + virtual std::string GetPlainTextEntry(const RefPtr<UnifiedData>& unifiedData) = 0; | ||
| 79 | + virtual void GetHtmlEntry( | ||
| 80 | + const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent) = 0; | ||
| 81 | + virtual void GetLinkEntry(const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description) = 0; | ||
| 82 | + virtual bool GetFileUriEntry(const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri) = 0; | ||
| 83 | + virtual std::vector<uint8_t> GetSpanStringEntry(const RefPtr<UnifiedData>& unifiedData) = 0; | ||
| 76 | }; | 84 | }; |
| 77 | } // namespace OHOS::Ace | 85 | } // namespace OHOS::Ace |
| 78 | 86 | ||
| @@ -113,7 +113,7 @@ | |||
| 113 | 113 | ||
| 114 | namespace OHOS::Ace::NG { | 114 | namespace OHOS::Ace::NG { |
| 115 | namespace { | 115 | namespace { |
| 116 | - | 116 | + |
| 117 | const BorderRadiusProperty ZERO_BORDER_RADIUS_PROPERTY(0.0_vp); | 117 | const BorderRadiusProperty ZERO_BORDER_RADIUS_PROPERTY(0.0_vp); |
| 118 | // need to be moved to TextFieldTheme | 118 | // need to be moved to TextFieldTheme |
| 119 | constexpr Dimension BORDER_DEFAULT_WIDTH = 0.0_vp; | 119 | constexpr Dimension BORDER_DEFAULT_WIDTH = 0.0_vp; |
| @@ -2036,26 +2036,25 @@ std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)> Tex | |||
| 2036 | } | 2036 | } |
| 2037 | auto data = event->GetData(); | 2037 | auto data = event->GetData(); |
| 2038 | CHECK_NULL_VOID(data); | 2038 | CHECK_NULL_VOID(data); |
| 2039 | + | ||
| 2039 | std::string str; | 2040 | std::string str; |
| 2040 | - auto arr = UdmfClient::GetInstance()->GetSpanStringRecord(data); | 2041 | + auto arr = UdmfClient::GetInstance()->GetSpanStringEntry(data); |
| 2041 | if (arr.size() > 0) { | 2042 | if (arr.size() > 0) { |
| 2042 | auto spanStr = SpanString::DecodeTlv(arr); | 2043 | auto spanStr = SpanString::DecodeTlv(arr); |
| 2043 | str += spanStr->GetString(); | 2044 | str += spanStr->GetString(); |
| 2044 | } else { | 2045 | } else { |
| 2045 | - auto records = UdmfClient::GetInstance()->GetPlainTextRecords(data); | 2046 | + auto plainText = UdmfClient::GetInstance()->GetPlainTextEntry(data); |
| 2046 | - if (records.empty()) { | 2047 | + if (plainText.empty()) { |
| 2047 | std::string linkUrl; | 2048 | std::string linkUrl; |
| 2048 | std::string linkTitle; | 2049 | std::string linkTitle; |
| 2049 | - UdmfClient::GetInstance()->GetLinkRecord(data, linkUrl, linkTitle); | 2050 | + UdmfClient::GetInstance()->GetLinkEntry(data, linkUrl, linkTitle); |
| 2050 | if (!linkTitle.empty()) { | 2051 | if (!linkTitle.empty()) { |
| 2051 | str += linkTitle; | 2052 | str += linkTitle; |
| 2052 | } else if (!linkUrl.empty()) { | 2053 | } else if (!linkUrl.empty()) { |
| 2053 | str += linkUrl; | 2054 | str += linkUrl; |
| 2054 | } | 2055 | } |
| 2055 | } | 2056 | } |
| 2056 | - for (const auto& record : records) { | 2057 | + str += plainText; |
| 2057 | - str += record; | ||
| 2058 | - } | ||
| 2059 | } | 2058 | } |
| 2060 | pattern->dragRecipientStatus_ = DragStatus::NONE; | 2059 | pattern->dragRecipientStatus_ = DragStatus::NONE; |
| 2061 | if (str.empty()) { | 2060 | if (str.empty()) { |
| @@ -6422,7 +6421,7 @@ void TextFieldPattern::PlayScrollBarAppearAnimation() | |||
| 6422 | scrollBar->PlayScrollBarAppearAnimation(); | 6421 | scrollBar->PlayScrollBarAppearAnimation(); |
| 6423 | } | 6422 | } |
| 6424 | } | 6423 | } |
| 6425 | - | 6424 | + |
| 6426 | void TextFieldPattern::ScheduleDisappearDelayTask() | 6425 | void TextFieldPattern::ScheduleDisappearDelayTask() |
| 6427 | { | 6426 | { |
| 6428 | auto scrollBar = GetScrollBar(); | 6427 | auto scrollBar = GetScrollBar(); |
| @@ -1484,6 +1484,7 @@ NG::DragDropInfo WebPattern::HandleOnDragStart(const RefPtr<OHOS::Ace::DragEvent | |||
| 1484 | UdmfClient::GetInstance()->AddLinkRecord(aceUnifiedData, linkUrl, linkTitle); | 1484 | UdmfClient::GetInstance()->AddLinkRecord(aceUnifiedData, linkUrl, linkTitle); |
| 1485 | TAG_LOGI(AceLogTag::ACE_WEB, "web DragDrop event Start, linkUrl size:%{public}zu", linkUrl.size()); | 1485 | TAG_LOGI(AceLogTag::ACE_WEB, "web DragDrop event Start, linkUrl size:%{public}zu", linkUrl.size()); |
| 1486 | } | 1486 | } |
| 1487 | + UdmfClient::GetInstance()->SetTagProperty(aceUnifiedData, "records_to_entries_data_format"); | ||
| 1487 | info->SetData(aceUnifiedData); | 1488 | info->SetData(aceUnifiedData); |
| 1488 | HandleOnDragEnter(info); | 1489 | HandleOnDragEnter(info); |
| 1489 | return dragDropInfo; | 1490 | return dragDropInfo; |
| @@ -1852,7 +1853,7 @@ void WebPattern::HandleOnDragDropLink(RefPtr<UnifiedData> aceData) | |||
| 1852 | // hyperlink | 1853 | // hyperlink |
| 1853 | std::string linkUrl; | 1854 | std::string linkUrl; |
| 1854 | std::string linkTitle; | 1855 | std::string linkTitle; |
| 1855 | - UdmfClient::GetInstance()->GetLinkRecord(aceData, linkUrl, linkTitle); | 1856 | + UdmfClient::GetInstance()->GetLinkEntry(aceData, linkUrl, linkTitle); |
| 1856 | if (!linkUrl.empty()) { | 1857 | if (!linkUrl.empty()) { |
| 1857 | delegate_->dragData_->SetLinkURL(linkUrl); | 1858 | delegate_->dragData_->SetLinkURL(linkUrl); |
| 1858 | delegate_->dragData_->SetLinkTitle(linkTitle); | 1859 | delegate_->dragData_->SetLinkTitle(linkTitle); |
| @@ -1871,7 +1872,7 @@ void WebPattern::HandleOnDragDropFile(RefPtr<UnifiedData> aceData) | |||
| 1871 | CHECK_NULL_VOID(delegate_->dragData_); | 1872 | CHECK_NULL_VOID(delegate_->dragData_); |
| 1872 | // file | 1873 | // file |
| 1873 | std::vector<std::string> urlVec; | 1874 | std::vector<std::string> urlVec; |
| 1874 | - UdmfClient::GetInstance()->GetFileUriRecord(aceData, urlVec); | 1875 | + UdmfClient::GetInstance()->GetFileUriEntry(aceData, urlVec); |
| 1875 | TAG_LOGI(AceLogTag::ACE_WEB, "DragDrop event WebEventHub onDragDropId," | 1876 | TAG_LOGI(AceLogTag::ACE_WEB, "DragDrop event WebEventHub onDragDropId," |
| 1876 | "url array size is:%{public}zu", urlVec.size()); | 1877 | "url array size is:%{public}zu", urlVec.size()); |
| 1877 | delegate_->dragData_->ClearImageFileNames(); | 1878 | delegate_->dragData_->ClearImageFileNames(); |
| @@ -1921,9 +1922,8 @@ void WebPattern::HandleOnDragDrop(const RefPtr<OHOS::Ace::DragEvent>& info) | |||
| 1921 | "DragDrop event WebEventHub onDragDropId, size:%{public}" PRId64 "", aceData->GetSize()); | 1922 | "DragDrop event WebEventHub onDragDropId, size:%{public}" PRId64 "", aceData->GetSize()); |
| 1922 | CHECK_NULL_VOID(delegate_->dragData_); | 1923 | CHECK_NULL_VOID(delegate_->dragData_); |
| 1923 | // plain text | 1924 | // plain text |
| 1924 | - std::vector<std::string> plains = UdmfClient::GetInstance()->GetPlainTextRecords(aceData); | 1925 | + std::string plain = UdmfClient::GetInstance()->GetPlainTextEntry(aceData); |
| 1925 | - if (!plains.empty() && !plains[0].empty()) { | 1926 | + if (!plain.empty()) { |
| 1926 | - std::string plain = plains[0]; | ||
| 1927 | delegate_->dragData_->SetFragmentText(plain); | 1927 | delegate_->dragData_->SetFragmentText(plain); |
| 1928 | TAG_LOGI(AceLogTag::ACE_WEB, | 1928 | TAG_LOGI(AceLogTag::ACE_WEB, |
| 1929 | "DragDrop event WebEventHub onDragDropId, plain size:%{public}zu", plain.size()); | 1929 | "DragDrop event WebEventHub onDragDropId, plain size:%{public}zu", plain.size()); |
| @@ -1931,14 +1931,14 @@ void WebPattern::HandleOnDragDrop(const RefPtr<OHOS::Ace::DragEvent>& info) | |||
| 1931 | // html | 1931 | // html |
| 1932 | std::string htmlContent; | 1932 | std::string htmlContent; |
| 1933 | std::string plainContent; | 1933 | std::string plainContent; |
| 1934 | - UdmfClient::GetInstance()->GetHtmlRecord(aceData, htmlContent, plainContent); | 1934 | + UdmfClient::GetInstance()->GetHtmlEntry(aceData, htmlContent, plainContent); |
| 1935 | if (!htmlContent.empty()) { | 1935 | if (!htmlContent.empty()) { |
| 1936 | delegate_->dragData_->SetFragmentHtml(htmlContent); | 1936 | delegate_->dragData_->SetFragmentHtml(htmlContent); |
| 1937 | TAG_LOGI(AceLogTag::ACE_WEB, | 1937 | TAG_LOGI(AceLogTag::ACE_WEB, |
| 1938 | "DragDrop event WebEventHub onDragDropId, htmlContent size:%{public}zu", htmlContent.size()); | 1938 | "DragDrop event WebEventHub onDragDropId, htmlContent size:%{public}zu", htmlContent.size()); |
| 1939 | } | 1939 | } |
| 1940 | // spanstring | 1940 | // spanstring |
| 1941 | - std::vector<uint8_t> spanString = UdmfClient::GetInstance()->GetSpanStringRecord(aceData); | 1941 | + std::vector<uint8_t> spanString = UdmfClient::GetInstance()->GetSpanStringEntry(aceData); |
| 1942 | if (!spanString.empty()) { | 1942 | if (!spanString.empty()) { |
| 1943 | std::string htmlStr = OHOS::Ace::SpanToHtml::ToHtml(spanString); | 1943 | std::string htmlStr = OHOS::Ace::SpanToHtml::ToHtml(spanString); |
| 1944 | delegate_->dragData_->SetFragmentHtml(htmlStr); | 1944 | delegate_->dragData_->SetFragmentHtml(htmlStr); |
| @@ -66,6 +66,16 @@ public: | |||
| 66 | MOCK_METHOD( | 66 | MOCK_METHOD( |
| 67 | int32_t, StartAsyncDataRetrieval, (napi_env env, napi_value napiValue, const std::string& key), (override)); | 67 | int32_t, StartAsyncDataRetrieval, (napi_env env, napi_value napiValue, const std::string& key), (override)); |
| 68 | MOCK_METHOD(int32_t, Cancel, (const std::string& key), (override)); | 68 | MOCK_METHOD(int32_t, Cancel, (const std::string& key), (override)); |
| 69 | + | ||
| 70 | + MOCK_METHOD(void, SetTagProperty, (const RefPtr<UnifiedData>& unifiedData, const std::string& tag), (override)); | ||
| 71 | + MOCK_METHOD(std::string, GetPlainTextEntry, (const RefPtr<UnifiedData>& unifiedData), (override)); | ||
| 72 | + MOCK_METHOD(void, GetHtmlEntry, | ||
| 73 | + (const RefPtr<UnifiedData>& unifiedData, std::string& htmlContent, std::string& plainContent), (override)); | ||
| 74 | + MOCK_METHOD(void, GetLinkEntry, | ||
| 75 | + (const RefPtr<UnifiedData>& unifiedData, std::string& url, std::string& description), (override)); | ||
| 76 | + MOCK_METHOD( | ||
| 77 | + bool, GetFileUriEntry, (const RefPtr<UnifiedData>& unifiedData, std::vector<std::string>& uri), (override)); | ||
| 78 | + MOCK_METHOD(std::vector<uint8_t>, GetSpanStringEntry, (const RefPtr<UnifiedData>& unifiedData), (override)); | ||
| 69 | }; | 79 | }; |
| 70 | class MockUnifiedData : public UnifiedData { | 80 | class MockUnifiedData : public UnifiedData { |
| 71 | DECLARE_ACE_TYPE(MockUnifiedData, UnifiedData); | 81 | DECLARE_ACE_TYPE(MockUnifiedData, UnifiedData); |