Skip to content

feat(reader): support OFD documents rendering - #383

Merged
deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:feat-ofd-support
Sep 14, 2026
Merged

deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:feat-ofd-support

Conversation

@add-uos

@add-uos add-uos commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

ofd_support 分支的 OFD 文档支持作为新功能整体进入 master,并包含渲染修复与文档清理。

功能内容(基于 rofd C ABI)

  • OFD 文档接入:通过 rofd C ABI(librofd-ffi)解析并渲染 OFD 文档(feat(reader): add OFD document support via rofd C ABI
  • 构建依赖:依赖发行版 librofd-ffi 包(build: depend on distro librofd-ffi packages for OFD support
  • 语义文本:OFD 语义文本支持、文档元数据/标识符暴露、解析警告透出
  • 目录与导航:完整 OFD 目录树、类型化导航目标、页面链接接入
  • 有界渲染:页面区域渲染,避免整页位图内存分配
  • UI:阅读器界面集成 OFD 搜索、缩略图外观对齐护眼模式

附加提交

  • fix(reader): clamp OFD render slices to page canvas:大图渲染任务按 1000px 分片时末尾分片未截断到页宽,导致 OfdDocument::renderPage 拒绝越界请求(OFD render region outside canvas);同时放大镜请求矩形收敛到画布内
  • chore(docs): remove non-standard docs/superpowers directory:移除开发期临时设计文档目录(不规范),REUSE 检查恢复全绿

依赖说明

rofd 侧的诊断修复见 linuxdeepin/rofd#3(新增 ROFD_DIAGNOSTIC_SINGULAR_TRANSFORM ABI 常量),建议 rofd PR 先行合入。

Checklist

  • 本地 reuse lint 1953/1953 合规
  • 单测:OFD 31 项 + 浏览器 87 项通过(obj-testsQT_QPA_PLATFORM=offscreen
  • 真实文档验证:4 个 fixture 目录 110 页渲染 0 失败

Summary by Sourcery

Correct OFD page rendering near canvas boundaries and remove temporary development documentation.

Bug Fixes:

  • Prevent OFD rendering failures and blank page areas by keeping render slices and magnifier requests within the page canvas.

Documentation:

  • Remove temporary non-standard OFD design and planning documents.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @add-uos, your pull request is larger than the review limit of 150,000 diff characters

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 96 分 (通过阈值: 70分)

Fail


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码质量高,新增OFD文档格式支持功能完整,URI安全处理规范,资源管理完善,测试覆盖全面

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['代码空指针检查、整数溢出检查、浮点数有限性检查均十分完善,边界条件处理得当']


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['统一 OfdModel.cpp/h 的版权声明格式,移除冗余的 Copyright (C) 行', '统一"Warnings"的中文翻译', "测试代码中使用 friend 类替代 '#define private public' 宏技巧", '考虑将 renderPage 中的 Cairo 表面创建和诊断处理拆分为辅助函数']


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['ThumbnailDelegate 的 nightPixmap 缓存避免了重复逐像素反色计算,设计合理', 'OfdDocument 的导航页矩形缓存和目录缓存采用懒加载+互斥锁保护,性能优良', '渲染分片机制限制了内存使用上限,避免了大图渲染的内存爆炸']


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: ['URI 安全处理设计优秀:allowedUri() 仅允许 http/https/mailto 协议,显式拒绝 file://、javascript:、data: 等危险协议', '外部 URI 打开前通过 SecurityDialog 确认,防止恶意链接自动打开', 'resolveNavigationUri() 使用 StrictMode 解析并二次验证,防止 URI 注入', '渲染函数对画布边界、步长限制、光栅字节上限均有校验,防止缓冲区溢出', '所有 rofd 资源使用 unique_ptr + 自定义删除器管理,无资源泄漏风险', 'size_t 到 int 转换均有 numeric_limits 上限检查,防止整数溢出']


💡 改进建议代码示例

// 暂无代码示例

本报告由 AI 代码审查工具自动生成

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文档大图分片与放大镜渲染不再产生越界请求,页面右侧不再缺失。
docs/superpowers 目录为开发过程中的临时设计记录与计划文档,
不符合项目正式文档规范,按维护要求整体移除。相关设计说明由
代码注释与 rofd 仓库文档承载。

Log: 移除不规范的docs/superpowers目录
Influence: 仅删除开发期文档,不影响编译、功能与打包。
@add-uos

add-uos commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 7eb905e into linuxdeepin:master Sep 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants