diff --git a/clay/lynx_adaptor/painting_context_clay.cc b/clay/lynx_adaptor/painting_context_clay.cc index 9c56623b5b..3a8158871a 100644 --- a/clay/lynx_adaptor/painting_context_clay.cc +++ b/clay/lynx_adaptor/painting_context_clay.cc @@ -296,7 +296,8 @@ void PaintingContextClay::UpdateLayout(int tag, float x, float y, float width, const float* margins, const float* borders, const float* bounds, const float* sticky, - float max_height, uint32_t node_index) { + float max_height, uint32_t node_index, + bool /*display_none*/) { const std::array paddings_copy = {paddings[0], paddings[1], paddings[2], paddings[3]}; const std::array margins_copy = {margins[0], margins[1], margins[2], diff --git a/clay/lynx_adaptor/painting_context_clay.h b/clay/lynx_adaptor/painting_context_clay.h index 586aa900fe..b1af74c194 100644 --- a/clay/lynx_adaptor/painting_context_clay.h +++ b/clay/lynx_adaptor/painting_context_clay.h @@ -109,8 +109,8 @@ class PaintingContextClay : public PaintingCtxPlatformImpl, void UpdateLayout(int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* bounds, - const float* sticky, float max_height, - uint32_t node_index) override; + const float* sticky, float max_height, uint32_t node_index, + bool display_none) override; void Invoke(int64_t id, const std::string& method, const pub::Value& params, const std::function& callback) override; diff --git a/core/public/painting_ctx_platform_impl.h b/core/public/painting_ctx_platform_impl.h index 2a1b5621cb..dddf342966 100644 --- a/core/public/painting_ctx_platform_impl.h +++ b/core/public/painting_ctx_platform_impl.h @@ -141,7 +141,8 @@ class PaintingCtxPlatformImpl { float height, const float* paddings, const float* margins, const float* borders, const float* bounds, const float* sticky, - float max_height, uint32_t node_index) = 0; + float max_height, uint32_t node_index, + bool display_none) = 0; virtual void RecordInitialLynxUITreeForReplay( std::vector nodes) {} virtual void UpdatePlatformExtraBundle(int32_t id, diff --git a/core/renderer/dom/element.cc b/core/renderer/dom/element.cc index b0eeab2b7c..0ef33042e2 100644 --- a/core/renderer/dom/element.cc +++ b/core/renderer/dom/element.cc @@ -400,7 +400,7 @@ void Element::UpdateLayout(float left, float top, float width, float height, const std::array& margins, const std::array& borders, const std::array* sticky_positions, - float max_height) { + float max_height, bool display_none) { TRACE_EVENT(LYNX_TRACE_CATEGORY, ELEMENT_UPDATE_LAYOUT); // TODO: only leaf node need to update border padding frame_changed_ = true; @@ -411,6 +411,7 @@ void Element::UpdateLayout(float left, float top, float width, float height, paddings_ = paddings; margins_ = margins; borders_ = borders; + display_none_ = display_none; UpdateStickyPosition(sticky_positions); MarkSubtreeNeedUpdate(); NotifyElementSizeUpdated(); diff --git a/core/renderer/dom/element.h b/core/renderer/dom/element.h index f2923d7bd6..7e9ac85b45 100644 --- a/core/renderer/dom/element.h +++ b/core/renderer/dom/element.h @@ -718,7 +718,7 @@ class Element : public lepus::RefCounted, const std::array& margins, const std::array& borders, const std::array* sticky_positions, - float max_height); + float max_height, bool display_none = false); // Used to update child element's left and top value from list element. The // another overloaded function is used to update layout info from starlight, // but if the element is list's child, the left and top's value are always 0. @@ -878,6 +878,7 @@ class Element : public lepus::RefCounted, float height() { return height_; } float top() { return top_; } float left() { return left_; } + bool display_none() { return display_none_; } bool enable_new_animator() { return enable_new_animator_; } @@ -1543,6 +1544,7 @@ class Element : public lepus::RefCounted, bool subtree_need_update_{false}; bool frame_changed_{false}; + bool display_none_{false}; // Determine by Catalyzer bool is_layout_only_{false}; diff --git a/core/renderer/dom/element_container.cc b/core/renderer/dom/element_container.cc index 2fe696efa3..d01dfd4a0c 100644 --- a/core/renderer/dom/element_container.cc +++ b/core/renderer/dom/element_container.cc @@ -419,7 +419,7 @@ void ElementContainer::UpdateLayout(float left, float top, element()->height(), element()->paddings().data(), element()->margins().data(), element()->borders().data(), nullptr, GetStickyPositionIfNeeded(), element()->max_height(), - element()->NodeIndex()); + element()->NodeIndex(), element()->display_none()); } if (need_update_impl || props_changed_) { painting_context()->OnNodeReady(element()->impl_id()); diff --git a/core/renderer/dom/fiber/fiber_element.cc b/core/renderer/dom/fiber/fiber_element.cc index b959b948c3..1756ec76c9 100644 --- a/core/renderer/dom/fiber/fiber_element.cc +++ b/core/renderer/dom/fiber/fiber_element.cc @@ -5601,6 +5601,7 @@ void FiberElement::UpdateLayoutInfo() { borders_[1] = layout_result.border_[starlight::kTop]; borders_[2] = layout_result.border_[starlight::kRight]; borders_[3] = layout_result.border_[starlight::kBottom]; + display_none_ = sl_node_->GetShouldDisplayNone(); if (IsShadowNodeCustom()) { element_manager_->layout_context()->OnLayout(id_, left_, top_, width_, diff --git a/core/renderer/dom/fragment/fragment.cc b/core/renderer/dom/fragment/fragment.cc index 9d36f297af..bbd3cea0c0 100644 --- a/core/renderer/dom/fragment/fragment.cc +++ b/core/renderer/dom/fragment/fragment.cc @@ -1088,7 +1088,7 @@ void Fragment::OnDraw(DisplayListBuilder& display_list_builder) { } void Fragment::DrawFull(DisplayListBuilder& display_list_builder) { - if (element()->IsShadowNodeVirtual()) { + if (element()->IsShadowNodeVirtual() || element()->display_none()) { // No contents to be rendered for virtual shadow nodes. return; } @@ -1161,9 +1161,24 @@ void Fragment::Draw() { builder.Reserve(draw_node_capacity_); } - OnDraw(builder); + if (!element()->display_none()) { + OnDraw(builder); - CheckRootIfNeedClipBounds(builder); + CheckRootIfNeedClipBounds(builder); + } else { + // display:none: still emit a display list containing only this node's + // Begin/End so the platform layer receives an update and clears any stale + // content / sublayers / event-target state instead of keeping the previous + // frame. + builder.Begin(id(), + behavior_ == nullptr ? PlatformRendererType::kUnknown + : behavior_->GetType(), + layout_info_.layout_result.offset_.X(), + layout_info_.layout_result.offset_.Y(), + layout_info_.layout_result.size_.width_, + layout_info_.layout_result.size_.height_); + builder.End(); + } painting_context()->impl()->CastToNativeCtx()->UpdateDisplayList( id(), builder.Build()); diff --git a/core/renderer/dom/fragment/fragment_unittest.cc b/core/renderer/dom/fragment/fragment_unittest.cc index 59803d7762..2f2d510c61 100644 --- a/core/renderer/dom/fragment/fragment_unittest.cc +++ b/core/renderer/dom/fragment/fragment_unittest.cc @@ -96,9 +96,7 @@ class TestPlatformRenderer : public PlatformRendererImpl { protected: void OnUpdateDisplayList(DisplayList display_list) override { - if (display_list.HasContent()) { - display_list_ = std::move(display_list); - } + display_list_ = std::move(display_list); } void OnUpdateAttributes(const fml::RefPtr&, bool) override {} void OnAddChild(PlatformRenderer*, int) override {} @@ -144,6 +142,111 @@ class TestNativePaintingCtxPlatformRef : public NativePaintingCtxPlatformRef { std::unordered_set scrollable_signs; }; +// Adapter that exposes the NativePaintingContext interface expected by +// Fragment::Draw() and forwards to a TestNativePaintingCtxPlatformRef. +class TestNativePaintingContext : public NativePaintingContext { + public: + void SetPlatformRef(TestNativePaintingCtxPlatformRef* ref) { ref_ = ref; } + + void OnFirstScreen() override {} + void FinishTasmOperation( + const std::shared_ptr& options) override {} + void FinishLayoutOperation( + const std::shared_ptr& options) override {} + void CreatePlatformRenderer( + int id, PlatformRendererType type, + const fml::RefPtr& init_data) override { + if (ref_) { + ref_->CreatePlatformRenderer(id, type, init_data); + } + } + void CreatePlatformExtendedRenderer( + int id, const base::String& tag_name, + const fml::RefPtr& init_data) override { + if (ref_) { + ref_->CreatePlatformExtendedRenderer(id, tag_name, init_data); + } + } + void UpdateDisplayList(int id, DisplayList list) override { + if (ref_) { + ref_->UpdateDisplayList(id, std::move(list)); + } + } + void CreateImage(int id, base::String src, float width, float height, + int32_t event_mask = 0) override {} + void UpdateTextBundle(int id, intptr_t bundle) override {} + void DestroyTextBundle(int id) override {} + void InsertListItemPaintingNode(int32_t list_id, int32_t child_id) override {} + void RemoveListItemPaintingNode(int32_t list_id, int32_t child_id) override {} + void UpdateContentOffsetForListContainer(int32_t container_id, + float content_size, float delta_x, + float delta_y, + bool is_init_scroll_offset, + bool from_layout) override {} + void ReconstructEventTargetTreeRecursively() override { + if (ref_) { + ref_->ReconstructEventTargetTreeRecursively(); + } + } + void UpdatePlatformEventBundle(int id, PlatformEventBundle bundle) override { + if (ref_) { + ref_->UpdatePlatformEventBundle(id, std::move(bundle)); + } + } + + private: + TestNativePaintingCtxPlatformRef* ref_ = nullptr; +}; + +// A MockPaintingContext whose platform ref is a real +// NativePaintingCtxPlatformRef so that Fragment::Draw() can exercise +// UpdateDisplayList / event-target reconstruction paths. +class NativeMockPaintingContext : public MockPaintingContext, + public TestNativePaintingContext { + public: + NativeMockPaintingContext() { + auto ref = std::make_shared(); + platform_ref_ = ref; + SetPlatformRef(ref.get()); + } + + NativePaintingContext* CastToNativeCtx() override { return this; } + + TestNativePaintingCtxPlatformRef* GetNativePlatformRef() { + return static_cast(platform_ref_.get()); + } +}; + +class FragmentDrawTest : public ::testing::Test { + public: + FragmentDrawTest() {} + ~FragmentDrawTest() override {} + + void SetUp() override { + LynxEnvConfig lynx_env_config(kConfigWidth, kConfigHeight, + kDefaultLayoutsUnitPerPx, + kDefaultPhysicalPixelsPerLayoutUnit); + tasm_mediator = std::make_shared< + ::testing::NiceMock>(); + manager = std::make_unique( + std::make_unique(), tasm_mediator.get(), + lynx_env_config); + auto config = std::make_shared(); + manager->page_options_.embedded_mode_ = static_cast( + static_cast(manager->page_options_.embedded_mode_) | + static_cast(EmbeddedMode::FRAGMENT_LAYER_RENDER)); + manager->page_options_.embedded_mode_ = static_cast( + static_cast(manager->page_options_.embedded_mode_) | + static_cast(EmbeddedMode::LAYOUT_IN_ELEMENT)); + config->SetEnableZIndex(true); + config->SetEnableFiberArch(true); + manager->SetConfig(config); + } + + std::unique_ptr manager; + std::shared_ptr<::testing::NiceMock> tasm_mediator; +}; + TEST_F(FragmentTest, CreateLayerIfNeededWritesFlattenInitData) { auto element = manager->CreateFiberText("text"); element->MarkAsDirectChildOfCompatibleComponent(true); @@ -1050,5 +1153,66 @@ TEST_F(FragmentTest, OutsetShadowWithZeroSizeElement) { EXPECT_GE(list.GetContentOpTypesSize(), 1u); } +TEST_F(FragmentDrawTest, + DisplayNoneEmitsEmptyDisplayListAndReconstructsExposure) { + auto page = manager->CreateFiberPage("0", 0); + ASSERT_NE(page, nullptr); + page->FlushActionsAsRoot(); + ASSERT_TRUE(page->HasElementContainer()); + + auto* fragment = static_cast(page->element_container()); + ASSERT_NE(fragment, nullptr); + + // Ensure the page fragment has a behavior and a backing platform renderer. + page->SetupFragmentBehavior(fragment); + auto* native_ctx = static_cast( + fragment->painting_context()->impl()) + ->GetNativePlatformRef(); + ASSERT_NE(native_ctx, nullptr); + native_ctx->CreatePlatformRenderer(fragment->id(), + PlatformRendererType::kPage, nullptr); + fragment->has_platform_renderer_ = true; + + starlight::LayoutResultForRendering layout; + layout.border_ = starlight::DirectionValue({0.f, 0.f, 0.f, 0.f}); + layout.padding_ = starlight::DirectionValue({0.f, 0.f, 0.f, 0.f}); + layout.size_ = FloatSize(100.f, 60.f); + fragment->UpdateLayout(layout); + + // Give the page a background so the visible draw produces more than + // Begin/End. + page->computed_css_style()->background_data_ = starlight::BackgroundData(); + page->computed_css_style()->background_data_->color = 0xFF00FF00; + + auto renderer_it = native_ctx->renderers_.find(fragment->id()); + ASSERT_NE(renderer_it, native_ctx->renderers_.end()); + auto* renderer = + static_cast(renderer_it->second.get()); + + // When visible, Draw() produces a display list with background content. + page->display_none_ = false; + fragment->Draw(); + EXPECT_TRUE(renderer->display_list_.HasContent()); + const size_t visible_op_count = + renderer->display_list_.GetContentOpTypesSize(); + EXPECT_GT(visible_op_count, 2u); + + // When display_none becomes true, Draw() must still send a display list that + // contains only this node's Begin/End so the platform layer clears stale + // content / sublayers / event-target state instead of keeping the previous + // frame. It must also still run ReconstructEventTargetTreeForExposure for the + // root. + page->display_none_ = true; + manager->MarkNeedReconstructEventTargetTreeForExposure(); + fragment->Draw(); + EXPECT_FALSE(manager->NeedReconstructEventTargetTreeForExposure()); + EXPECT_TRUE(renderer->display_list_.HasContent()); + EXPECT_EQ(renderer->display_list_.GetContentOpTypesSize(), 2u); + const int32_t* ops = renderer->display_list_.GetContentOpTypesData(); + ASSERT_NE(ops, nullptr); + EXPECT_EQ(ops[0], static_cast(DisplayListOpType::kBegin)); + EXPECT_EQ(ops[1], static_cast(DisplayListOpType::kEnd)); +} + } // namespace tasm } // namespace lynx diff --git a/core/renderer/dom/testing/fiber_mock_painting_context.cc b/core/renderer/dom/testing/fiber_mock_painting_context.cc index cec070e279..714bbf9c1d 100644 --- a/core/renderer/dom/testing/fiber_mock_painting_context.cc +++ b/core/renderer/dom/testing/fiber_mock_painting_context.cc @@ -132,7 +132,8 @@ void FiberMockPaintingContext::UpdatePaintingNode( void FiberMockPaintingContext::UpdateLayout( int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* bounds, - const float* sticky, float max_height, uint32_t node_index) { + const float* sticky, float max_height, uint32_t node_index, + bool /*display_none*/) { EnqueueOperation([this, x, y, width, height, tag]() -> void { if (node_map_.find(tag) == node_map_.end()) { return; diff --git a/core/renderer/dom/testing/fiber_mock_painting_context.h b/core/renderer/dom/testing/fiber_mock_painting_context.h index 6e338a5e6f..3a1cf41f33 100644 --- a/core/renderer/dom/testing/fiber_mock_painting_context.h +++ b/core/renderer/dom/testing/fiber_mock_painting_context.h @@ -55,8 +55,8 @@ class FiberMockPaintingContext : public PaintingContextPlatformImpl { void UpdateLayout(int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* bounds, - const float* sticky, float max_height, - uint32_t node_index) override; + const float* sticky, float max_height, uint32_t node_index, + bool display_none) override; void SetKeyframes(fml::RefPtr keyframes_data) override; diff --git a/core/renderer/tasm/react/testing/mock_painting_context.h b/core/renderer/tasm/react/testing/mock_painting_context.h index 9945e31273..84ac45b690 100644 --- a/core/renderer/tasm/react/testing/mock_painting_context.h +++ b/core/renderer/tasm/react/testing/mock_painting_context.h @@ -165,7 +165,8 @@ class MockPaintingContext : public PaintingContextPlatformImpl { float height, const float* paddings, const float* margins, const float* borders, const float* bounds, const float* sticky, - float max_height, uint32_t node_index) override { + float max_height, uint32_t node_index, + bool /*display_none*/) override { std::lock_guard guard(lock_); if (node_map_.find(tag) == node_map_.end()) { diff --git a/core/renderer/ui_wrapper/layout/empty/layout_context_empty_implementation.h b/core/renderer/ui_wrapper/layout/empty/layout_context_empty_implementation.h index 5502adfd7d..94af709a4c 100644 --- a/core/renderer/ui_wrapper/layout/empty/layout_context_empty_implementation.h +++ b/core/renderer/ui_wrapper/layout/empty/layout_context_empty_implementation.h @@ -23,7 +23,7 @@ class DelegateEmptyImpl : public LayoutContext::Delegate { const std::array& margins, const std::array& borders, const std::array* sticky_positions, - float max_height) override {} + float max_height, bool display_none) override {} virtual void OnLayoutAfter(const std::shared_ptr& options, std::unique_ptr holder, bool has_layout) override {} diff --git a/core/renderer/ui_wrapper/layout/layout_context.cc b/core/renderer/ui_wrapper/layout/layout_context.cc index f92bcb9cf5..6c0326ed20 100644 --- a/core/renderer/ui_wrapper/layout/layout_context.cc +++ b/core/renderer/ui_wrapper/layout/layout_context.cc @@ -942,9 +942,11 @@ void LayoutContext::UpdateLayoutInfo(LayoutNode* node) { } } + bool display_none = sl_node->GetShouldDisplayNone(); delegate_->OnLayoutUpdate( node->id(), left, top, width, height, paddings, margins, borders, - sticky_positions, sl_node->GetCSSStyle()->GetMaxHeight().GetRawValue()); + sticky_positions, sl_node->GetCSSStyle()->GetMaxHeight().GetRawValue(), + display_none); if (node->slnode()->GetSLMeasureFunc()) { // Dispatch OnLayoutAfter to those nodes that have custom measure diff --git a/core/renderer/ui_wrapper/layout/layout_context.h b/core/renderer/ui_wrapper/layout/layout_context.h index 2175763de3..db66579682 100644 --- a/core/renderer/ui_wrapper/layout/layout_context.h +++ b/core/renderer/ui_wrapper/layout/layout_context.h @@ -60,7 +60,7 @@ class LayoutContext : public std::enable_shared_from_this, const std::array& margins, const std::array& borders, const std::array* sticky_positions, - float max_height) = 0; + float max_height, bool display_none) = 0; void OnLayoutAfter(const std::shared_ptr& options) { OnLayoutAfter(options, nullptr, false); }; diff --git a/core/renderer/ui_wrapper/painting/android/native_painting_context_android.cc b/core/renderer/ui_wrapper/painting/android/native_painting_context_android.cc index 1e56de149b..1dddd33312 100644 --- a/core/renderer/ui_wrapper/painting/android/native_painting_context_android.cc +++ b/core/renderer/ui_wrapper/painting/android/native_painting_context_android.cc @@ -293,7 +293,8 @@ void NativePaintingCtxAndroid::CreatePlatformExtendedRenderer( void NativePaintingCtxAndroid::UpdateLayout( int tag, float x, float y, float width, float height, const float *paddings, const float *margins, const float *borders, const float *bounds, - const float *sticky, float max_height, uint32_t node_index) {} + const float *sticky, float max_height, uint32_t node_index, + bool /*display_none*/) {} void NativePaintingCtxAndroid::UpdatePlatformExtraBundle( int32_t id, PlatformExtraBundle *bundle) { diff --git a/core/renderer/ui_wrapper/painting/android/native_painting_context_android.h b/core/renderer/ui_wrapper/painting/android/native_painting_context_android.h index e07a219251..62b7766f52 100644 --- a/core/renderer/ui_wrapper/painting/android/native_painting_context_android.h +++ b/core/renderer/ui_wrapper/painting/android/native_painting_context_android.h @@ -52,8 +52,8 @@ class NativePaintingCtxAndroid : public PaintingCtxPlatformImpl, void UpdateLayout(int tag, float x, float y, float width, float height, const float *paddings, const float *margins, const float *borders, const float *bounds, - const float *sticky, float max_height, - uint32_t node_index) override; + const float *sticky, float max_height, uint32_t node_index, + bool display_none) override; void UpdatePlatformExtraBundle(int32_t id, PlatformExtraBundle *bundle) override; diff --git a/core/renderer/ui_wrapper/painting/android/painting_context_android.cc b/core/renderer/ui_wrapper/painting/android/painting_context_android.cc index c700d2705b..b280f03b7c 100644 --- a/core/renderer/ui_wrapper/painting/android/painting_context_android.cc +++ b/core/renderer/ui_wrapper/painting/android/painting_context_android.cc @@ -695,7 +695,8 @@ void PaintingContextAndroid::DestroyPaintingNode(int parent, int child, void PaintingContextAndroid::UpdateLayout( int id, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* bounds, - const float* sticky, float max_height, uint32_t node_index) { + const float* sticky, float max_height, uint32_t node_index, + bool /*display_none*/) { patching_ids_.emplace_back(id); patching_node_index_.emplace_back(node_index); if (bounds != nullptr) { diff --git a/core/renderer/ui_wrapper/painting/android/painting_context_android.h b/core/renderer/ui_wrapper/painting/android/painting_context_android.h index cfe6a34288..98ee6748b6 100644 --- a/core/renderer/ui_wrapper/painting/android/painting_context_android.h +++ b/core/renderer/ui_wrapper/painting/android/painting_context_android.h @@ -100,8 +100,8 @@ class PaintingContextAndroid : public PaintingCtxPlatformImpl { void UpdateLayout(int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* bounds, - const float* sticky, float max_height, - uint32_t node_index) override; + const float* sticky, float max_height, uint32_t node_index, + bool display_none) override; void RecordInitialLynxUITreeForReplay( std::vector nodes) override; void UpdatePlatformExtraBundle(int32_t id, diff --git a/core/renderer/ui_wrapper/painting/empty/painting_context_implementation.h b/core/renderer/ui_wrapper/painting/empty/painting_context_implementation.h index ed85441188..3867c582f9 100644 --- a/core/renderer/ui_wrapper/painting/empty/painting_context_implementation.h +++ b/core/renderer/ui_wrapper/painting/empty/painting_context_implementation.h @@ -46,7 +46,8 @@ class PaintingContextPlatformImpl : public PaintingCtxPlatformImpl { float height, const float* paddings, const float* margins, const float* borders, const float* bounds, const float* sticky, - float max_height, uint32_t node_index) override {} + float max_height, uint32_t node_index, + bool /*display_none*/) override {} virtual void SetKeyframes(fml::RefPtr keyframes_data) override {} virtual void Flush() override {} virtual void HandleValidate(int tag) override {} diff --git a/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.cc b/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.cc index 57a46bde55..6aadd94a61 100644 --- a/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.cc +++ b/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.cc @@ -136,7 +136,7 @@ void PaintingContextHarmonyRef::ConsumeGesture(int64_t id, int32_t gesture_id, void PaintingContextHarmonyRef::UpdateLayout( int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* sticky, - float max_height, uint32_t node_index) { + float max_height, uint32_t node_index, bool /*display_none*/) { ui_owner_->UpdateLayout(tag, x, y, width, height, paddings, margins, sticky, max_height, node_index); } @@ -222,7 +222,8 @@ void PaintingContextHarmony::UpdatePaintingNode( void PaintingContextHarmony::UpdateLayout( int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* bounds, - const float* sticky, float max_height, uint32_t node_index) { + const float* sticky, float max_height, uint32_t node_index, + bool display_none) { #define MAKE_UNIQUE_COPY(src, size) \ std::unique_ptr src##_copy{nullptr}; \ if (src) { \ @@ -242,12 +243,13 @@ void PaintingContextHarmony::UpdateLayout( Enqueue([platform_ref = platform_ref_, tag, x, y, width, height, paddings = std::move(paddings_copy), margins = std::move(margins_copy), borders = std::move(borders_copy), - sticky = std::move(sticky_copy), max_height, node_index] { + sticky = std::move(sticky_copy), max_height, node_index, + display_none] { auto harmony_ref = std::static_pointer_cast(platform_ref); harmony_ref->UpdateLayout(tag, x, y, width, height, paddings.get(), margins.get(), borders.get(), sticky.get(), - max_height, node_index); + max_height, node_index, display_none); }); } diff --git a/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.h b/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.h index 939e60ef52..b9f0205ca0 100644 --- a/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.h +++ b/core/renderer/ui_wrapper/painting/harmony/painting_context_harmony.h @@ -57,7 +57,7 @@ class PaintingContextHarmonyRef : public PaintingCtxPlatformRef { void UpdateLayout(int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* sticky, float max_height, - uint32_t node_index); + uint32_t node_index, bool display_none); void OnLayoutFinish(int32_t list_comp_id, int64_t operation_id); void StopExposure(const lepus::Value& options); void ResumeExposure(); @@ -90,8 +90,8 @@ class PaintingContextHarmony : public PaintingCtxPlatformImpl { void UpdateLayout(int tag, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* bounds, - const float* sticky, float max_height, - uint32_t node_index) override; + const float* sticky, float max_height, uint32_t node_index, + bool display_none) override; void SetKeyframes(fml::RefPtr keyframes_data) override; void Flush() override; void HandleValidate(int tag) override; diff --git a/core/renderer/ui_wrapper/painting/ios/native_painting_context_darwin.h b/core/renderer/ui_wrapper/painting/ios/native_painting_context_darwin.h index df8462a1f8..e26d463ae0 100644 --- a/core/renderer/ui_wrapper/painting/ios/native_painting_context_darwin.h +++ b/core/renderer/ui_wrapper/painting/ios/native_painting_context_darwin.h @@ -46,7 +46,8 @@ class NativePaintingCtxDarwin : public PaintingCtxPlatformImpl, public NativePai // NativePaintingContextDarwin do not need impl this interface. void UpdateLayout(int tag, float x, float y, float width, float height, const float *paddings, const float *margins, const float *borders, const float *bounds, - const float *sticky, float max_height, uint32_t node_index) override {} + const float *sticky, float max_height, uint32_t node_index, + bool /*display_none*/) override {} // NativePaintingContextDarwin do not need impl this interface. void SetKeyframes(fml::RefPtr keyframes_data) override {} diff --git a/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.h b/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.h index f687c9b137..5497026edd 100644 --- a/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.h +++ b/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.h @@ -85,8 +85,8 @@ class PaintingContextDarwin : public PaintingCtxPlatformImpl { void UpdateLayout(int sign, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* flatten_bounds, - const float* sticky, float max_height, - uint32_t node_index) override; + const float* sticky, float max_height, uint32_t node_index, + bool display_none) override; std::unique_ptr GetTextInfo(const std::string& content, const pub::Value& info) override; void StopExposure(const pub::Value& options) override; diff --git a/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.mm b/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.mm index 46a42591a5..69f57ea65e 100644 --- a/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.mm +++ b/core/renderer/ui_wrapper/painting/ios/painting_context_darwin.mm @@ -426,8 +426,8 @@ void RunOnMainThreadSync(dispatch_block_t block) { void PaintingContextDarwin::UpdateLayout(int sign, float x, float y, float width, float height, const float* paddings, const float* margins, const float* borders, const float* flatten_bounds, - const float* sticky, float max_height, - uint32_t node_index) { + const float* sticky, float max_height, uint32_t node_index, + bool /*display_none*/) { // top left bottom right for UIEdgeInset #define UI_EDGE_INSETS(array) \ array != nullptr ? UIEdgeInsetsMake(array[1], array[0], array[3], array[2]) : UIEdgeInsetsZero diff --git a/core/renderer/ui_wrapper/painting/painting_context.h b/core/renderer/ui_wrapper/painting/painting_context.h index 47ca4f6468..eec29ef732 100644 --- a/core/renderer/ui_wrapper/painting/painting_context.h +++ b/core/renderer/ui_wrapper/painting/painting_context.h @@ -92,10 +92,10 @@ class PaintingContext { const float* paddings, const float* margins, const float* borders, const float* bounds, const float* sticky, float max_height, - uint32_t node_index) { + uint32_t node_index, bool display_none) { platform_impl_->UpdateLayout(tag, x, y, width, height, paddings, margins, borders, bounds, sticky, max_height, - node_index); + node_index, display_none); } inline void RecordInitialLynxUITreeForReplay( diff --git a/core/shell/layout_mediator.cc b/core/shell/layout_mediator.cc index 5823e38cb3..da155da43d 100644 --- a/core/shell/layout_mediator.cc +++ b/core/shell/layout_mediator.cc @@ -32,7 +32,8 @@ void LayoutMediator::OnLayoutUpdate( int tag, float x, float y, float width, float height, const std::array &paddings, const std::array &margins, const std::array &borders, - const std::array *sticky_positions, float max_height) { + const std::array *sticky_positions, float max_height, + bool display_none) { std::array sticky_positions_clone; bool has_sticky = false; if (sticky_positions) { @@ -43,15 +44,17 @@ void LayoutMediator::OnLayoutUpdate( if (node_manager_ != nullptr) { operation_queue_->EnqueueOperation( [node_manager = node_manager_, tag, x, y, width, height, paddings, - margins, borders, sticky_positions_clone, has_sticky, max_height]() { + margins, borders, sticky_positions_clone, has_sticky, max_height, + display_none]() { auto *node = node_manager->Get(tag); if (node != nullptr) { if (has_sticky) { node->UpdateLayout(x, y, width, height, paddings, margins, - borders, &sticky_positions_clone, max_height); + borders, &sticky_positions_clone, max_height, + display_none); } else { node->UpdateLayout(x, y, width, height, paddings, margins, - borders, nullptr, max_height); + borders, nullptr, max_height, display_none); } } else { LOGE( diff --git a/core/shell/layout_mediator.h b/core/shell/layout_mediator.h index 318d1477bc..9f16c2d1c3 100644 --- a/core/shell/layout_mediator.h +++ b/core/shell/layout_mediator.h @@ -43,7 +43,7 @@ class LayoutMediator : public tasm::LayoutContext::Delegate, const std::array &margins, const std::array &borders, const std::array *sticky_positions, - float max_height) override; + float max_height, bool display_none) override; void OnLayoutAfter(const std::shared_ptr &option, std::unique_ptr holder, bool has_layout) override; diff --git a/core/shell/testing/mock_layout_delegate.h b/core/shell/testing/mock_layout_delegate.h index 69fd450af2..d3bca0d5e1 100644 --- a/core/shell/testing/mock_layout_delegate.h +++ b/core/shell/testing/mock_layout_delegate.h @@ -25,7 +25,7 @@ class MockLayoutDelegate : public LayoutContext::Delegate { const std::array& margins, const std::array& borders, const std::array* sticky_positions, - float max_height) override {} + float max_height, bool /*display_none*/) override {} void PostPlatformExtraBundle( int32_t id, std::unique_ptr bundle) override {} void OnCalculatedViewportChanged(const CalculatedViewport& viewport,