mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
View HTML: Show matched rules: ignore style & tweaks on long-press
On long-press on the "Show matched stylesheets rules" buttons, ignore those from our epub.css/html5.css and from styletweaks, which may make investigating a book style simpler without their noise.
This commit is contained in:
@@ -946,8 +946,8 @@ function CreDocument:getHTMLFromXPointers(xp0, xp1, flags, from_root_node)
|
||||
end
|
||||
end
|
||||
|
||||
function CreDocument:getStylesheetsMatchingRulesets(node_dataindex)
|
||||
return self._document:getStylesheetsMatchingRulesets(node_dataindex)
|
||||
function CreDocument:getStylesheetsMatchingRulesets(node_dataindex, with_main_stylesheet)
|
||||
return self._document:getStylesheetsMatchingRulesets(node_dataindex, with_main_stylesheet)
|
||||
end
|
||||
|
||||
function CreDocument:getNormalizedXPointer(xp)
|
||||
|
||||
@@ -353,12 +353,20 @@ function ViewHtml:_handleLongPress(document, css_selectors_offsets, offset_shift
|
||||
callback = function()
|
||||
self:_showMatchingSelectors(document, ancestors, false)
|
||||
end,
|
||||
hold_callback = function()
|
||||
-- skip main stylesheet and style tweaks
|
||||
self:_showMatchingSelectors(document, ancestors, false, false)
|
||||
end,
|
||||
}})
|
||||
table.insert(copy_buttons, {{
|
||||
text = _("Show matched stylesheets rules (all ancestors)"),
|
||||
callback = function()
|
||||
self:_showMatchingSelectors(document, ancestors, true)
|
||||
end,
|
||||
hold_callback = function()
|
||||
-- skip main stylesheet and style tweaks
|
||||
self:_showMatchingSelectors(document, ancestors, true, false)
|
||||
end,
|
||||
}})
|
||||
|
||||
local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
|
||||
@@ -372,11 +380,11 @@ function ViewHtml:_handleLongPress(document, css_selectors_offsets, offset_shift
|
||||
UIManager:show(widget)
|
||||
end
|
||||
|
||||
function ViewHtml:_showMatchingSelectors(document, ancestors, show_all_ancestors)
|
||||
function ViewHtml:_showMatchingSelectors(document, ancestors, show_all_ancestors, with_main_stylesheet)
|
||||
local snippets
|
||||
if not show_all_ancestors then
|
||||
local node_dataindex = ancestors[1][2]
|
||||
snippets = document:getStylesheetsMatchingRulesets(node_dataindex)
|
||||
snippets = document:getStylesheetsMatchingRulesets(node_dataindex, with_main_stylesheet)
|
||||
else
|
||||
snippets = {}
|
||||
local elements = {}
|
||||
@@ -391,8 +399,11 @@ function ViewHtml:_showMatchingSelectors(document, ancestors, show_all_ancestors
|
||||
table.insert(snippets, "")
|
||||
end
|
||||
local desc = table.concat(elements, " > ", 1, #ancestors - i + 1)
|
||||
table.insert(snippets, "/* ====== " .. desc .. " */")
|
||||
util.arrayAppend(snippets, document:getStylesheetsMatchingRulesets(node_dataindex))
|
||||
-- We use Unicode solid black blocks to make these really visible
|
||||
table.insert(snippets, "/* \u{259B}" .. ("\u{2580}"):rep(20) .. " */")
|
||||
table.insert(snippets, "/* \u{258C}" .. desc .. " */")
|
||||
table.insert(snippets, "/* \u{2599}" .. ("\u{2584}"):rep(20) .. " */")
|
||||
util.arrayAppend(snippets, document:getStylesheetsMatchingRulesets(node_dataindex, with_main_stylesheet))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user