Repository navigation
refactor: remove fileIdentifier/imageObjectRects features - #460
deepin-bot[bot] merged 1 commit into
Conversation
|
TAG Bot TAG: 6.6.6 |
Reviewer's GuideAPIMove image-object rectangle lookup from the page interface to the document interface, and declare the PDF document’s implementation of the new interface.
Uses of the APIRoute image-object rectangle requests through the new document-level interface so PDF documents can provide the night-mode mask data.
ImplementationImplement PDF image-object detection through PDFium, including rotated-page coordinate mapping and password-aware probe loading, and extract the PDF’s persistent identifier from its trailer.
ConfigurationBuild and bundle deepin-pdfium from the pinned source revision, adjust package dependencies, and record the package-version update.
TestsAdd a regression test that checks PDF image-object rectangles are present, positive-sized, and within expected page bounds.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="reader/app/Database.cpp" line_range="387" />
<code_context>
-
- // docId 未命中时,回退到 fileSize + contentHash 匹配
- if (bestRow.isEmpty()) {
+ {
QSqlQuery query(m_database);
+ // 通过 fileSize + contentHash 匹配(同一份内容的移动/重命名/副本)
</code_context>
<issue_to_address>
**Different PDFs inherit reading history**
When two different documents have the same size and identical first and last 64 KB but differ in between, `matchOperationByContent` accepts the sampled `fileSize` and `contentHash` match, so it migrates the other document’s operation state and bookmarks; `setAlive` restores that reading position for the new document.
Verify that the full file contents match before migrating operation state or bookmarks.
Also at `reader/app/Database.cpp:389-393`.
</issue_to_address>
### Comment 2
<location path="reader/app/Database.cpp" line_range="125" />
<code_context>
",fileSize INTEGER DEFAULT 0"
",lastModified INTEGER DEFAULT 0"
",contentHash TEXT DEFAULT ''"
- ",docId TEXT DEFAULT ''"
",lastOpened INTEGER DEFAULT 0"
")")) {
</code_context>
<issue_to_address>
**Downgrade cannot save reading state**
When a database is first created by this version and then opened by an older reader release, the older reader’s `saveOperation` still inserts into `operation.docId`; because this schema omits that column and `migrateOperationTable` no longer adds it, saving state after downgrading fails with a missing-column error.
Keep the `docId` column in newly created schemas for backward compatibility, even if this version no longer reads or writes it.
</issue_to_address>
### Comment 3
<location path="reader/app/Database.cpp" line_range="387" />
<code_context>
-
- // docId 未命中时,回退到 fileSize + contentHash 匹配
- if (bestRow.isEmpty()) {
+ {
QSqlQuery query(m_database);
+ // 通过 fileSize + contentHash 匹配(同一份内容的移动/重命名/副本)
</code_context>
<issue_to_address>
**Unhashable files inherit unrelated state**
When the file exists but cannot be opened for hashing, and an unrelated operation row has the same file size and an empty contentHash, `computeContentHash` returns an empty string, and `matchOperationByContent` treats it as a valid content match; a same-sized row with an empty hash is then borrowed or migrated, so the opened file gets another document’s reading state.
Reject content matching when the computed hash is empty, and avoid storing failed hash computations as matchable values.
</issue_to_address>|
|
||
| // docId 未命中时,回退到 fileSize + contentHash 匹配 | ||
| if (bestRow.isEmpty()) { | ||
| { |
There was a problem hiding this comment.
🟡 Medium · Different PDFs inherit reading history
When two different documents have the same size and identical first and last 64 KB but differ in between, matchOperationByContent accepts the sampled fileSize and contentHash match, so it migrates the other document’s operation state and bookmarks; setAlive restores that reading position for the new document.
Verify that the full file contents match before migrating operation state or bookmarks.
Also at reader/app/Database.cpp:389-393.
Prompt for AI agents
In `reader/app/Database.cpp` at line 387:
**Different PDFs inherit reading history**
When two different documents have the same size and identical first and last 64 KB but differ in between, `matchOperationByContent` accepts the sampled `fileSize` and `contentHash` match, so it migrates the other document’s operation state and bookmarks; `setAlive` restores that reading position for the new document.
Verify that the full file contents match before migrating operation state or bookmarks.
Also at `reader/app/Database.cpp:389-393`.|
|
||
| // docId 未命中时,回退到 fileSize + contentHash 匹配 | ||
| if (bestRow.isEmpty()) { | ||
| { |
There was a problem hiding this comment.
🟡 Medium · Unhashable files inherit unrelated state
When the file exists but cannot be opened for hashing, and an unrelated operation row has the same file size and an empty contentHash, computeContentHash returns an empty string, and matchOperationByContent treats it as a valid content match; a same-sized row with an empty hash is then borrowed or migrated, so the opened file gets another document’s reading state.
Reject content matching when the computed hash is empty, and avoid storing failed hash computations as matchable values.
Prompt for AI agents
In `reader/app/Database.cpp` at line 387:
**Unhashable files inherit unrelated state**
When the file exists but cannot be opened for hashing, and an unrelated operation row has the same file size and an empty contentHash, `computeContentHash` returns an empty string, and `matchOperationByContent` treats it as a valid content match; a same-sized row with an empty hash is then borrowed or migrated, so the opened file gets another document’s reading state.
Reject content matching when the computed hash is empty, and avoid storing failed hash computations as matchable values.530fc45 to
12fbf9b
Compare
|
/merge |
|
This pr cannot be merged! (status: blocked) |
1. Restore the imageObjectRects night-mode feature (renderer prefetch, BrowserPage paste-back, thumbnail bbox cache, IMAGE_NIGHT_MASK role, night image policy options and NightFilter object masks): photos in night mode are no longer inverted, only text/background is 2. libdeepin-pdfium 1.5.x lacks the old Qt-level imageObjectRects, but exports the full PDFium C API; PDFDocument now enumerates page objects (FPDFPage_CountObjects/GetObject/GetBounds with rotation mapping) through a lazily created second FPDF document handle, and the document password is passed through for encrypted files 3. Keep the fileIdentifier/docId matching: DPdfDoc has no /ID accessor on 1.5.x, so PDFDocument parses the permanent /ID straight from the PDF trailer/xref dictionary (hex and literal string syntax, latest incremental trailer wins) 4. linglong: build deepin-pdfium from source (pinned d9e73d2) into the package, replacing the apt libdeepin-pdfium runtime dependency Influence: 1. Open and render PDF/DOCX/XPS/OFD documents, verify normal reading, annotation and printing still work 2. Toggle night mode on a photo-containing PDF: photo areas keep their colors (object mask), text/background inverted as before 3. Rename or move a PDF (even after saving annotations) and reopen it: reading history still matches via the parsed permanent /ID refactor: 通过 PDFium C API 探测恢复夜间蒙版功能 1. 恢复 imageObjectRects 夜间模式功能(渲染线程预取、BrowserPage 回贴、 缩略图 bbox 缓存、IMAGE_NIGHT_MASK 角色、夜间图片策略选项与 NightFilter 对象蒙版):夜间模式下照片不再被反色,仅文字/背景反转 2. libdeepin-pdfium 1.5.x 缺少原 Qt 级 imageObjectRects 接口,但导出了 完整 PDFium C API;PDFDocument 通过懒加载的第二个 FPDF 文档句柄枚举 页面对象(FPDFPage_CountObjects/GetObject/GetBounds,含旋转映射), 加密文档的密码从加载链路传入 3. 保留 fileIdentifier/docId 阅读记录匹配:libdeepin-pdfium 1.5.x 无 /ID 接口,PDFDocument 直接解析 PDF trailer/xref 字典中的永久 /ID (支持 hex 与字面量两种语法,取最新增量 trailer 的值) 4. 玲珑构建改为源码编译 deepin-pdfium(钉住 d9e73d2)随包分发, 移除 apt libdeepin-pdfium 运行时依赖 Influence: 1. 打开并渲染 PDF/DOCX/XPS/OFD 文档,验证阅读、批注、打印正常 2. 含照片的 PDF 开启夜间模式:照片区域保持原色(对象蒙版), 文字/背景照常反转 3. PDF 保存批注后移动/重命名再打开:阅读记录仍按解析出的永久 /ID 匹配 Log: restores the night-mode image mask feature via the PDFium C API exported by libdeepin-pdfium 1.5.8 and builds the engine from source in linglong PMS: TASK-398545
12fbf9b to
27b1ae1
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, 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 |
|
/merge |
说明 / Summary
在 #456(切换系统库 libdeepin-pdfium 1.5.8)基础上,通过库导出的 PDFium C API 恢复夜间模式图片对象蒙版功能,功能零损失:
libdeepin-pdfium 1.5.8虽无 Qt 级imageObjectRects接口,但导出了完整 PDFium C API(231 个FPDF_*符号)。PDFDocument通过懒加载的第二个FPDF文档句柄枚举页面对象(FPDFPage_CountObjects/GetObject),过滤FPDF_PAGEOBJ_IMAGE并用FPDFPageObj_GetBounds取包围盒,含旋转映射,逻辑与原内嵌实现逐行对齐;加密文档密码从加载链路传入PDFDocument解析 PDF trailer/xref 字典中的永久 /ID(hex 与字面量语法均支持),解析失败自动回退 fileSize+contentHash 匹配Restore the night-mode image object masks on top of the system libdeepin-pdfium 1.5.8 by using its exported PDFium C API; the /ID-based reading-history matching is kept, and the linglong build now compiles deepin-pdfium from source into the package.
测试建议 / Test
PMS: TASK-398545