Conversation
The big-image task split pages into 1000px-wide tiles without clamping the last tile to the actual page width. Pages whose width was not a multiple of 1000 produced out-of-canvas requests that the OFD document model rejects, leaving the right edge unpainted. The magnifier (getImagePoint) could also request rects beyond the canvas near page edges; intersect the rect with the canvas first. 大图任务按1000px分片时末尾未截断到页面实际宽度,页宽非1000整数倍 时越界请求被OFD文档模型拒绝,页面右侧无法绘制;放大镜在页边悬停 时同样可能越界,先与整页画布求交集。 Log: 修复OFD分片越界导致页面右侧渲染缺失 Influence: OFD文档大图分片与放大镜渲染不再产生越界请求,页面右侧不再缺失。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFix OFD rendering gaps and magnifier failures by constraining caller-generated regions to the page canvas: tiled rendering now truncates the final slice, and point-based magnifier requests are intersected with the scaled canvas while the renderer’s strict validation remains unchanged. Sequence diagram for clamped OFD page renderingsequenceDiagram
participant PageRenderThread
participant OfdDocument
PageRenderThread->>PageRenderThread: run()
loop Each 1000px slice
PageRenderThread->>OfdDocument: renderPage(clamped QRect)
OfdDocument-->>PageRenderThread: rendered slice
end
Note over PageRenderThread,OfdDocument: Final slice width is qMin(1000, task.rect.width() - i)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos 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 |
The ofd_support branch added four OFD design docs under docs/ without copyright or licensing declarations, which made the license-check workflow fail on every PR touching this branch. Add a dep5 entry covering docs/ with GPL-3.0-or-later, consistent with the source tree. ofd_support 分支在 docs/ 下新增了四个 OFD 设计文档,缺少版权与 许可声明,导致 license-check 流水线对所有 PR 都会失败。在 dep5 中补充 docs/ 条目,与源码目录一致使用 GPL-3.0-or-later。 Log: 补充docs目录REUSE声明修复流水线license-check失败 Influence: 仓库通过REUSE 3.3合规检查,docs目录许可与源码一致。
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰,边界处理完善。BrowserPage.cpp 中 getImagePoint 函数新增画布交集与空矩形检查,逻辑严谨;PageRenderThread.cpp 中分片循环重构为步进式遍历并使用 qMin 截断末尾分片宽度,逻辑正确。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码结构清晰,注释完整。建议将分片宽度 1000 提取为命名常量(如 kSliceWidth)以增强可维护性。新增的中文注释清晰解释了修复原因和背景。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。QRect::intersected() 为 O(1) 操作开销极低;重构后的分片循环移除了取模和条件运算,性能略有提升;新增的 rect.isEmpty() 检查避免了无效渲染器调用。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞。本次修复实际上增强了代码健壮性,通过画布交集和分片宽度截断防止了越界渲染请求。无用户输入处理风险,无硬编码密钥,无注入风险。 💡 改进建议代码示例// 建议将魔法数字提取为命名常量
static constexpr int kSliceWidth = 1000;
// PageRenderThread.cpp 改进示例
for (int i = 0; i < task.rect.width(); i += kSliceWidth) {
renderRects.append(QRect(i, 0, qMin(kSliceWidth, task.rect.width() - i), task.rect.height()));
}本报告由 AI 代码审查工具自动生成 |
问题
打开 OFD 文档时出现两类渲染异常(样例:发票监制章-数科.ofd):
<deepin_reader::OfdDocument::renderPage:493> OFD render region outside canvas: QRect(1000,0 1000x1542) QRect(0,0 1090x1542)QRect(1000,0,1000,1542)(右边界到 2000),越界请求被OfdDocument::renderPage的保护检查拒绝,页面右侧留白放大镜
BrowserPage::getImagePoint在悬停点靠近页边时同样产生越界请求矩形修复
均为调用方按契约收敛请求,保持
OfdDocument::renderPage的严格越界检查不变:reader/browser/PageRenderThread.cpp:分片循环改为步进累加 +qMin(1000, width - i),末尾分片自动截断reader/browser/BrowserPage.cpp:getImagePoint先将请求矩形与整页画布求交集(取整方式与getImage参数一致),空矩形直接返回空图验证
renderSmallRegionOnHugeCanvas、rejectInvalidRegions等既有越界契约用例)Summary by Sourcery
Clamp browser rendering requests to page boundaries so OFD documents render completely without rejected out-of-bounds regions.
Bug Fixes:
Enhancements:
Chores: