Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR prevents white flashes when switching Markdown from live preview to read-only mode in dark theme by synchronizing backgrounds at the QWidget, Chromium page, and theme-color application layers. Review regression coverage should focus on live preview/read-only transitions and dark/light theme changes. Sequence diagram for synchronized Markdown read-only background themesequenceDiagram
participant EditWrapper
participant ReadPage as ReadPage QWidget
participant MarkdownView
participant Chromium as Chromium Page
participant JSBridge as Theme JS Bridge
EditWrapper->>ReadPage: setAutoFillBackground(true)
EditWrapper->>ReadPage: setPalette(readPalette)
MarkdownView->>Chromium: setBackgroundColor(Qt.white)
EditWrapper->>MarkdownView: applyTheme(themeMap)
MarkdownView->>Chromium: setBackgroundColor(bgColor)
MarkdownView->>JSBridge: applyTheme(themeMap)
JSBridge-->>MarkdownView: CSS --bg updated
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: m_pReadPage container had no palette set in OnThemeChangeSlot, MarkdownView never called page()->setBackgroundColor(), and theme.css --bg defaults to #ffffff with dark value injected asynchronously via JS bridge 2. Fix: set m_pReadPage palette with background color in OnThemeChangeSlot, call page()->setBackgroundColor(Qt::white) in MarkdownView::init() as default, and page()->setBackgroundColor (bgColor) in applyTheme() to sync Chromium render layer 3. Impact: dark theme read-only view switch no longer flashes white; light theme behavior unchanged Log: fix white flash when switching to read-only view in dark theme Influence: 1. Test dark theme md file switch from live preview to read-only view 2. Test light theme same operation for no regression 3. Test theme switch (dark/light) updates read-only view background fix: 修复深色主题下只读视图切换白色闪烁 1. 根因:m_pReadPage 容器在 OnThemeChangeSlot 中未设置 palette, MarkdownView 从未调用 page()->setBackgroundColor(),theme.css 的 --bg 默认 #ffffff 且深色值经 JS bridge 异步注入 2. 方案:在 OnThemeChangeSlot 中为 m_pReadPage 设置背景色 palette, 在 MarkdownView::init() 调用 page()->setBackgroundColor(Qt::white) 设默认值,在 applyTheme() 同步 Chromium 渲染层背景色 3. 影响:深色主题下只读视图切换不再白色闪烁,浅色主题行为不变 Log: 修复深色主题下切换只读视图白色闪烁问题 Influence: 1. 测试深色主题下 md 文件从实时预览切换到只读视图无闪烁 2. 测试浅色主题下同样操作无回归 3. 测试主题切换(深色/浅色)时只读视图背景色正确更新 PMS: BUG-378219
61f45a1 to
9e3548d
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: 无改进建议 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: 无改进建议 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: 无改进建议 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: 无改进建议 💡 改进建议代码示例// 当前代码已足够完善,无需修改示例。 // editwrapper.cpp - 已有空指针检查和正确的 palette 设置 // markdownview.cpp - 已有 isValid() 校验和合理的默认值设置本报告由 AI 代码审查工具自动生成 |
Root Cause Analysis
When switching from live preview to read-only view in dark theme, a white flash appeared because three layers of background color protection were missing. The
m_pReadPageQWidget container had nosetAutoFillBackground/setPalettecall inOnThemeChangeSlot(editwrapper.cpp),MarkdownView(QWebEngineView subclass) never calledpage()->setBackgroundColor()so Chromium rendered a default white background (markdownview.cpp), andtheme.css--bgCSS variable defaults to#ffffffwith the dark value injected asynchronously via JS bridge — leaving a gap during the switch transition.Fix Approach
Added
m_pReadPagepalette setting inOnThemeChangeSlotafter the existingm_pBottomBar->setPalette()call, consistent with the existing pattern. Addedpage()->setBackgroundColor(Qt::white)inMarkdownView::init()beforeload()as the default, andpage()->setBackgroundColor(bgColor)inapplyTheme()to synchronously set the Chromium render layer background from the theme map'seditor-colors.background-color— closing the async JS bridge gap.Change Safety Assessment
Code Safety
setAutoFillBackground,setPalette,page()->setBackgroundColor), no function signature changes, no control flow modifications, no caller impactBusiness Impact Scope
EditWrapper::OnThemeChangeSlot(),MarkdownView::init(),MarkdownView::applyTheme()Verification Suggestion
Focus regression testing on dark theme Markdown view switching (live preview ↔ read-only) and theme toggle (dark ↔ light) to confirm background color correctness and no white flash.
根因分析
深色主题下从实时预览切换到只读视图时出现白色闪烁,原因是三层背景色防护均缺失。
m_pReadPageQWidget 容器在OnThemeChangeSlot中未设置setAutoFillBackground/setPalette(editwrapper.cpp);MarkdownView(QWebEngineView 子类)全代码无page()->setBackgroundColor()调用,Chromium 渲染默认白底(markdownview.cpp);theme.css的--bgCSS 变量默认#ffffff,深色值经异步 JS bridge 注入,切换瞬间 CSS 变量尚未更新。修复方案
在
OnThemeChangeSlot中已有的m_pBottomBar->setPalette()之后新增m_pReadPage的 palette 设置,与现有模式一致。在MarkdownView::init()的load()之前添加page()->setBackgroundColor(Qt::white)作为默认值,在applyTheme()中根据主题色同步设置 Chromium 渲染层背景色,消除异步 JS bridge 注入前的间隙。改动安全评估
代码安全评估
setAutoFillBackground、setPalette、page()->setBackgroundColor),无函数签名变更、无控制流修改、无调用者影响业务影响范围
EditWrapper::OnThemeChangeSlot()、MarkdownView::init()、MarkdownView::applyTheme()验证建议
回归测试重点:深色主题 Markdown 视图切换(实时预览 ↔ 只读)及主题切换(深色 ↔ 浅色),确认背景色正确且无白色闪烁。
Summary by Sourcery
Bug Fixes: