From 177551918f984ffd85f558e0eb6791af2b7a7d68 Mon Sep 17 00:00:00 2001 From: poire-z Date: Mon, 25 May 2020 22:39:59 +0200 Subject: [PATCH] bump_crengine: various fixes, tweaks and cleanups (#6188) Includes: - Don't reset invisible BR to display: inline - ldomTextCollector: handle inline-block/table as inline - Avoid re-rendering on font hinting mode change - List markers: fix positionning when floats involved - GIF decoding: avoid uneeded abort on LZW table overflow - Adds getUnknownEntities(), can help with debugging - Don't check stylesheet hashes when loading from cache - Hardcoded elements and attributes list: cleanup - Full rendering: 2 small optimisations - Strut confinning: deal with images earlier - lvtextfm: some cleanup and reordering cre.cpp: - fix getPageFromXPointer() and getPosFromXPointer() to not fail on invisible nodes and work on the next visible node (so links whose target is display:none can work). Add support for 2 settings one can set manually in reader.settings.reader.lua: ["cre_background_color"] = "0xccffcc", ["cre_background_image"] = "/path/to/bg_paper.jpg", --- base | 2 +- frontend/apps/reader/modules/readerrolling.lua | 5 +++++ frontend/document/credocument.lua | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/base b/base index ab837d73b..4a91eefe3 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit ab837d73bae87efeb92950b4f00b6b55e5d45927 +Subproject commit 4a91eefe3a42f926ebe262658c258c9929544836 diff --git a/frontend/apps/reader/modules/readerrolling.lua b/frontend/apps/reader/modules/readerrolling.lua index 5e1d24dff..cbf15737f 100644 --- a/frontend/apps/reader/modules/readerrolling.lua +++ b/frontend/apps/reader/modules/readerrolling.lua @@ -258,6 +258,11 @@ function ReaderRolling:onCloseDocument() end end logger.dbg("cre cache used:", cache_file_path or "none") + -- Unknown elements and attributes, uncomment if needed for debugging: + -- local elements, attributes, namespaces = self.ui.document:getUnknownEntities() + -- if elements ~= "" then logger.info("cre unknown elements: ", elements) end + -- if attributes ~= "" then logger.info("cre unknown attributes: ", attributes) end + -- if namespaces ~= "" then logger.info("cre unknown namespaces: ", namespaces) end end function ReaderRolling:onCheckDomStyleCoherence() diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 5d16baf11..4f171c245 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -205,6 +205,14 @@ function CreDocument:setupDefaultView() self._document:setIntProperty("crengine.page.header.font.size", G_reader_settings:readSetting("cre_header_status_font_size")) end + + -- One can set these to change from white background + if G_reader_settings:readSetting("cre_background_color") then + self:setBackgroundColor(G_reader_settings:readSetting("cre_background_color")) + end + if G_reader_settings:readSetting("cre_background_image") then + self:setBackgroundImage(G_reader_settings:readSetting("cre_background_image")) + end end function CreDocument:loadDocument(full_document) @@ -893,6 +901,11 @@ function CreDocument:setStatusLineProp(prop) self._document:setStringProperty("window.status.line", prop) end +function CreDocument:setBackgroundColor(bgcolor) -- use nil to set to white + logger.dbg("CreDocument: set background color", bgcolor) + self._document:setBackgroundColor(bgcolor) +end + function CreDocument:setBackgroundImage(img_path) -- use nil to unset logger.dbg("CreDocument: set background image", img_path) self._document:setBackgroundImage(img_path) @@ -941,6 +954,10 @@ function CreDocument:getStatistics() return self._document:getStatistics() end +function CreDocument:getUnknownEntities() + return self._document:getUnknownEntities() +end + function CreDocument:canHaveAlternativeToc() return true end