diff --git a/docs/used/NewEditor_Win32NoOpRedundancyCleanupPlan_完成归档_2026-04-23.md b/docs/used/NewEditor_Win32NoOpRedundancyCleanupPlan_完成归档_2026-04-23.md new file mode 100644 index 00000000..b8c6e15a --- /dev/null +++ b/docs/used/NewEditor_Win32NoOpRedundancyCleanupPlan_完成归档_2026-04-23.md @@ -0,0 +1,56 @@ +# NewEditor Win32 No-Op Redundancy Cleanup Plan + +日期:2026-04-23 + +## 目标 + +在 `new_editor/app/Platform/Win32` 内只清理可证明为 no-op 的真冗余代码,要求: + +- 必须减少代码量 +- 不改变现有 Win32 生命周期、即时帧、分路径刷新机制 +- 每个阶段完成后立即编译 `XCUIEditorApp` +- 每个阶段完成后立即执行 `new_editor` 启动/关闭冒烟 + +## 冗余判定 + +本次只处理两类已经确认的 no-op 冗余: + +1. `EditorWindowContentController` 接口中本就具备天然默认值的可选能力,被强制下发到 `EditorStandaloneUtilityWindowContentController`,形成一大片空 override 样板。 +2. `EditorUtilityWindowCoordinator` 中完全不产生行为的空接口: + - `RegisterExistingWindow` + - `RefreshWindowPresentation` + 以及它们在 host runtime / message dispatcher / window manager 中对应的空调用链。 + +## Phase A + +下沉 `EditorWindowContentController` 的可选默认行为,删除 utility content controller 的空 override / 空实现,只保留 utility 窗口真正需要的行为。 + +验证: + +- 编译 `XCUIEditorApp` +- 启动 `XCUIEditor.exe` +- 观察初始化与关闭日志是否正常 + +## Phase B + +删除 `EditorUtilityWindowCoordinator` 的空注册 / 空 presentation API 与所有调用点,只保留真正处理 utility window transfer request 的路径。 + +验证: + +- 编译 `XCUIEditorApp` +- 启动 `XCUIEditor.exe` +- 观察初始化与关闭日志是否正常 + +## 收口 + +- 更新计划状态 +- 将完成计划归档到 `docs/used` + +## 完成结果 + +- Phase A 完成:`EditorWindowContentController` 下沉了可选默认行为,`EditorStandaloneUtilityWindowContentController` 删除了大段空 override / 空实现。 +- Phase B 完成:`EditorUtilityWindowCoordinator` 的空注册 / 空 presentation API 及对应空调用链已经删除。 +- 两次验证均通过: + - `cmake --build build --config Debug --target XCUIEditorApp` + - 启动 `build/new_editor/Debug/XCUIEditor.exe` + - 运行日志出现新的 `initialize end` 与 `shutdown end` 闭环 diff --git a/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.cpp b/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.cpp index e61e0b48..281b9b69 100644 --- a/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.cpp +++ b/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.cpp @@ -15,22 +15,9 @@ EditorStandaloneUtilityWindowContentController:: EditorStandaloneUtilityWindowContentController:: ~EditorStandaloneUtilityWindowContentController() = default; -const UIEditorWorkspaceController* -EditorStandaloneUtilityWindowContentController::TryGetWorkspaceController() const { - return nullptr; -} - -UIEditorWorkspaceController* -EditorStandaloneUtilityWindowContentController::TryGetMutableWorkspaceController() { - return nullptr; -} - void EditorStandaloneUtilityWindowContentController::ReplaceWorkspaceController( UIEditorWorkspaceController) {} -void EditorStandaloneUtilityWindowContentController::Initialize( - const EditorWindowContentInitializationContext&) {} - void EditorStandaloneUtilityWindowContentController::Shutdown() { OnShutdown(); m_shellInteractionState = {}; @@ -42,8 +29,6 @@ void EditorStandaloneUtilityWindowContentController::ResetInteractionState() { OnResetInteractionState(); } -void EditorStandaloneUtilityWindowContentController::SetViewportSurfacePresentationEnabled(bool) {} - EditorWindowFrameTransferRequests EditorStandaloneUtilityWindowContentController::UpdateAndAppend( const EditorWindowContentFrameContext& context, @@ -74,9 +59,6 @@ EditorStandaloneUtilityWindowContentController::UpdateAndAppend( drawData); } -void EditorStandaloneUtilityWindowContentController::RenderRequestedViewports( - const ::XCEngine::Rendering::RenderContext&) {} - const UIEditorShellInteractionFrame& EditorStandaloneUtilityWindowContentController::GetShellFrame() const { return m_shellFrame; @@ -87,66 +69,11 @@ EditorStandaloneUtilityWindowContentController::GetShellInteractionState() const return m_shellInteractionState; } -void EditorStandaloneUtilityWindowContentController::SetExternalDockHostDropPreview( - const Widgets::UIEditorDockHostDropPreviewState&) {} - -void EditorStandaloneUtilityWindowContentController::ClearExternalDockHostDropPreview() {} - -bool EditorStandaloneUtilityWindowContentController::TryResolveDockTabDragHotspot( - std::string_view, - std::string_view, - const ::XCEngine::UI::UIPoint&, - ::XCEngine::UI::UIPoint&) const { - return false; -} - -UIEditorDockHostTabDropTarget -EditorStandaloneUtilityWindowContentController::ResolveDockTabDropTarget( - const ::XCEngine::UI::UIPoint&) const { - return {}; -} - -bool EditorStandaloneUtilityWindowContentController::HasHostedContentCapture() const { - return false; -} - -bool EditorStandaloneUtilityWindowContentController::HasShellInteractiveCapture() const { - return false; -} - -bool EditorStandaloneUtilityWindowContentController::HasInteractiveCapture() const { - return false; -} - -EditorWindowContentCursorKind -EditorStandaloneUtilityWindowContentController::GetHostedContentCursorKind() const { - return EditorWindowContentCursorKind::Arrow; -} - -EditorWindowContentCursorKind -EditorStandaloneUtilityWindowContentController::GetDockCursorKind() const { - return EditorWindowContentCursorKind::Arrow; -} - ::XCEngine::UI::UISize EditorStandaloneUtilityWindowContentController::ResolveMinimumOuterSize() const { return m_minimumOuterSize; } -bool EditorStandaloneUtilityWindowContentController::ShouldUseDetachedTitleBarTabStrip() const { - return false; -} - -std::string EditorStandaloneUtilityWindowContentController::ResolveTabStripTitleText( - std::string_view fallbackTitle) const { - return std::string(fallbackTitle); -} - -std::string EditorStandaloneUtilityWindowContentController::ResolveDetachedWindowTitleText( - std::string_view fallbackWindowTitle) const { - return std::string(fallbackWindowTitle); -} - void EditorStandaloneUtilityWindowContentController::OnShutdown() {} void EditorStandaloneUtilityWindowContentController::OnResetInteractionState() {} diff --git a/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.h b/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.h index 65ec1339..d964b7f9 100644 --- a/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.h +++ b/new_editor/app/Platform/Win32/EditorStandaloneUtilityWindowContentController.h @@ -26,47 +26,18 @@ public: const ::XCEngine::UI::UISize& minimumOuterSize); ~EditorStandaloneUtilityWindowContentController() override; - const UIEditorWorkspaceController* TryGetWorkspaceController() const override; - UIEditorWorkspaceController* TryGetMutableWorkspaceController() override; void ReplaceWorkspaceController(UIEditorWorkspaceController workspaceController) override; - - void Initialize(const EditorWindowContentInitializationContext& context) override; void Shutdown() override; void ResetInteractionState() override; - void SetViewportSurfacePresentationEnabled(bool enabled) override; EditorWindowFrameTransferRequests UpdateAndAppend( const EditorWindowContentFrameContext& context, ::XCEngine::UI::UIDrawData& drawData) override; - void RenderRequestedViewports( - const ::XCEngine::Rendering::RenderContext& renderContext) override; const UIEditorShellInteractionFrame& GetShellFrame() const override; const UIEditorShellInteractionState& GetShellInteractionState() const override; - void SetExternalDockHostDropPreview( - const Widgets::UIEditorDockHostDropPreviewState& preview) override; - void ClearExternalDockHostDropPreview() override; - - bool TryResolveDockTabDragHotspot( - std::string_view nodeId, - std::string_view panelId, - const ::XCEngine::UI::UIPoint& point, - ::XCEngine::UI::UIPoint& outHotspot) const override; - UIEditorDockHostTabDropTarget ResolveDockTabDropTarget( - const ::XCEngine::UI::UIPoint& point) const override; - - bool HasHostedContentCapture() const override; - bool HasShellInteractiveCapture() const override; - bool HasInteractiveCapture() const override; - EditorWindowContentCursorKind GetHostedContentCursorKind() const override; - EditorWindowContentCursorKind GetDockCursorKind() const override; - ::XCEngine::UI::UISize ResolveMinimumOuterSize() const override; - bool ShouldUseDetachedTitleBarTabStrip() const override; - std::string ResolveTabStripTitleText(std::string_view fallbackTitle) const override; - std::string ResolveDetachedWindowTitleText( - std::string_view fallbackWindowTitle) const override; protected: virtual void OnShutdown(); diff --git a/new_editor/app/Platform/Win32/EditorWindowContentController.h b/new_editor/app/Platform/Win32/EditorWindowContentController.h index 40ed2031..1e975500 100644 --- a/new_editor/app/Platform/Win32/EditorWindowContentController.h +++ b/new_editor/app/Platform/Win32/EditorWindowContentController.h @@ -2,6 +2,7 @@ #include "Platform/Win32/EditorWindowTransferRequests.h" +#include #include #include @@ -29,7 +30,6 @@ struct UISize; namespace XCEngine::UI::Editor { -struct UIEditorDockHostTabDropTarget; class UIEditorWorkspaceController; struct UIEditorShellInteractionFrame; @@ -80,47 +80,70 @@ class EditorWindowContentController { public: virtual ~EditorWindowContentController() = default; - virtual const UIEditorWorkspaceController* TryGetWorkspaceController() const = 0; - virtual UIEditorWorkspaceController* TryGetMutableWorkspaceController() = 0; + virtual const UIEditorWorkspaceController* TryGetWorkspaceController() const { + return nullptr; + } + virtual UIEditorWorkspaceController* TryGetMutableWorkspaceController() { + return nullptr; + } virtual void ReplaceWorkspaceController(UIEditorWorkspaceController workspaceController) = 0; - virtual void Initialize(const EditorWindowContentInitializationContext& context) = 0; - virtual void Shutdown() = 0; - virtual void ResetInteractionState() = 0; - virtual void SetViewportSurfacePresentationEnabled(bool enabled) = 0; + virtual void Initialize(const EditorWindowContentInitializationContext&) {} + virtual void Shutdown() {} + virtual void ResetInteractionState() {} + virtual void SetViewportSurfacePresentationEnabled(bool) {} virtual EditorWindowFrameTransferRequests UpdateAndAppend( const EditorWindowContentFrameContext& context, ::XCEngine::UI::UIDrawData& drawData) = 0; - virtual void RenderRequestedViewports( - const ::XCEngine::Rendering::RenderContext& renderContext) = 0; + virtual void RenderRequestedViewports(const ::XCEngine::Rendering::RenderContext&) {} virtual const UIEditorShellInteractionFrame& GetShellFrame() const = 0; virtual const UIEditorShellInteractionState& GetShellInteractionState() const = 0; virtual void SetExternalDockHostDropPreview( - const Widgets::UIEditorDockHostDropPreviewState& preview) = 0; - virtual void ClearExternalDockHostDropPreview() = 0; + const Widgets::UIEditorDockHostDropPreviewState&) {} + virtual void ClearExternalDockHostDropPreview() {} virtual bool TryResolveDockTabDragHotspot( - std::string_view nodeId, - std::string_view panelId, - const ::XCEngine::UI::UIPoint& point, - ::XCEngine::UI::UIPoint& outHotspot) const = 0; + std::string_view, + std::string_view, + const ::XCEngine::UI::UIPoint&, + ::XCEngine::UI::UIPoint&) const { + return false; + } virtual UIEditorDockHostTabDropTarget ResolveDockTabDropTarget( - const ::XCEngine::UI::UIPoint& point) const = 0; + const ::XCEngine::UI::UIPoint&) const { + return {}; + } - virtual bool HasHostedContentCapture() const = 0; - virtual bool HasShellInteractiveCapture() const = 0; - virtual bool HasInteractiveCapture() const = 0; - virtual EditorWindowContentCursorKind GetHostedContentCursorKind() const = 0; - virtual EditorWindowContentCursorKind GetDockCursorKind() const = 0; + virtual bool HasHostedContentCapture() const { + return false; + } + virtual bool HasShellInteractiveCapture() const { + return false; + } + virtual bool HasInteractiveCapture() const { + return false; + } + virtual EditorWindowContentCursorKind GetHostedContentCursorKind() const { + return EditorWindowContentCursorKind::Arrow; + } + virtual EditorWindowContentCursorKind GetDockCursorKind() const { + return EditorWindowContentCursorKind::Arrow; + } virtual ::XCEngine::UI::UISize ResolveMinimumOuterSize() const = 0; - virtual bool ShouldUseDetachedTitleBarTabStrip() const = 0; - virtual std::string ResolveTabStripTitleText(std::string_view fallbackTitle) const = 0; + virtual bool ShouldUseDetachedTitleBarTabStrip() const { + return false; + } + virtual std::string ResolveTabStripTitleText(std::string_view fallbackTitle) const { + return std::string(fallbackTitle); + } virtual std::string ResolveDetachedWindowTitleText( - std::string_view fallbackWindowTitle) const = 0; + std::string_view fallbackWindowTitle) const { + return std::string(fallbackWindowTitle); + } }; } // namespace XCEngine::UI::Editor::App diff --git a/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.cpp b/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.cpp index 73e8ae91..539cd3cc 100644 --- a/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.cpp +++ b/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.cpp @@ -161,11 +161,6 @@ std::string EditorWorkspaceWindowContentController::ResolveTabStripTitleText( return ResolveUIEditorDetachedWorkspaceTitle(m_workspaceController, fallbackTitle); } -std::string EditorWorkspaceWindowContentController::ResolveDetachedWindowTitleText( - std::string_view fallbackWindowTitle) const { - return std::string(fallbackWindowTitle); -} - std::unique_ptr CreateEditorWorkspaceWindowContentController( UIEditorWorkspaceController workspaceController) { return std::make_unique( diff --git a/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.h b/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.h index 2abfd915..0b9c2ec4 100644 --- a/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.h +++ b/new_editor/app/Platform/Win32/EditorWorkspaceWindowContentController.h @@ -54,8 +54,6 @@ public: ::XCEngine::UI::UISize ResolveMinimumOuterSize() const override; bool ShouldUseDetachedTitleBarTabStrip() const override; std::string ResolveTabStripTitleText(std::string_view fallbackTitle) const override; - std::string ResolveDetachedWindowTitleText( - std::string_view fallbackWindowTitle) const override; private: UIEditorWorkspaceController m_workspaceController = {}; diff --git a/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.cpp b/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.cpp index 040be134..ff50b22c 100644 --- a/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.cpp +++ b/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.cpp @@ -38,10 +38,6 @@ void EditorUtilityWindowCoordinator::BindLifecycleCoordinator( m_lifecycleCoordinator = &lifecycleCoordinator; } -void EditorUtilityWindowCoordinator::RegisterExistingWindow(EditorWindow&) {} - -void EditorUtilityWindowCoordinator::RefreshWindowPresentation(EditorWindow&) const {} - void EditorUtilityWindowCoordinator::HandleWindowFrameTransferRequests( EditorWindow& sourceWindow, const EditorWindowFrameTransferRequests& transferRequests) { diff --git a/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.h b/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.h index 12252cf5..b40aacf3 100644 --- a/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.h +++ b/new_editor/app/Platform/Win32/WindowManager/EditorUtilityWindowCoordinator.h @@ -16,8 +16,6 @@ public: ~EditorUtilityWindowCoordinator(); void BindLifecycleCoordinator(EditorWindowLifecycleCoordinator& lifecycleCoordinator); - void RegisterExistingWindow(EditorWindow& window); - void RefreshWindowPresentation(EditorWindow& window) const; void HandleWindowFrameTransferRequests( EditorWindow& sourceWindow, const EditorWindowFrameTransferRequests& transferRequests); diff --git a/new_editor/app/Platform/Win32/WindowManager/EditorWindowHostRuntime.cpp b/new_editor/app/Platform/Win32/WindowManager/EditorWindowHostRuntime.cpp index 06438794..5c7a6ce2 100644 --- a/new_editor/app/Platform/Win32/WindowManager/EditorWindowHostRuntime.cpp +++ b/new_editor/app/Platform/Win32/WindowManager/EditorWindowHostRuntime.cpp @@ -192,7 +192,6 @@ void EditorWindowHostRuntime::RenderAllWindows( if (window->m_chromeController->ConsumeSkipNextSteadyStateFrame()) { workspaceCoordinator.RefreshWindowPresentation(*window); - utilityCoordinator.RefreshWindowPresentation(*window); continue; } @@ -202,7 +201,6 @@ void EditorWindowHostRuntime::RenderAllWindows( m_editorContext, globalTabDragActive); workspaceCoordinator.RefreshWindowPresentation(*window); - utilityCoordinator.RefreshWindowPresentation(*window); if (!transferRequests.HasPendingRequests()) { continue; } diff --git a/new_editor/app/Platform/Win32/WindowManager/EditorWindowManager.cpp b/new_editor/app/Platform/Win32/WindowManager/EditorWindowManager.cpp index 032b592d..6bf9500e 100644 --- a/new_editor/app/Platform/Win32/WindowManager/EditorWindowManager.cpp +++ b/new_editor/app/Platform/Win32/WindowManager/EditorWindowManager.cpp @@ -41,7 +41,6 @@ EditorWindow* EditorWindowManager::CreateEditorWindow( m_hostRuntime->CreateEditorWindow(std::move(contentController), params); if (window != nullptr) { m_workspaceCoordinator->RegisterExistingWindow(*window); - m_utilityCoordinator->RegisterExistingWindow(*window); } return window; } diff --git a/new_editor/app/Platform/Win32/WindowManager/EditorWindowMessageDispatcher.cpp b/new_editor/app/Platform/Win32/WindowManager/EditorWindowMessageDispatcher.cpp index 8765eb0f..90bce9c0 100644 --- a/new_editor/app/Platform/Win32/WindowManager/EditorWindowMessageDispatcher.cpp +++ b/new_editor/app/Platform/Win32/WindowManager/EditorWindowMessageDispatcher.cpp @@ -78,7 +78,6 @@ void EditorWindowMessageDispatcher::FinalizeImmediateFrame( const DispatchContext& context, const EditorWindowFrameTransferRequests& transferRequests) { context.workspaceCoordinator.RefreshWindowPresentation(context.window); - context.utilityCoordinator.RefreshWindowPresentation(context.window); if (!transferRequests.HasPendingRequests()) { return; }