[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copt deduplicate: embedded_css, embedded_fonts #10876

Merged
merged 3 commits into from
Sep 6, 2023

Conversation

hius07
Copy link
Member
@hius07 hius07 commented Sep 5, 2023

Main discussion in #10763.


This change is Reviewable

@poire-z
Copy link
Contributor
poire-z commented Sep 5, 2023

I think you earlier posted a comment (that you removed?) about inlining the :toggleXyz() in the :onToggleXyz as they were used once ? Why the change of mind (or me imagining things !? :)

@hius07
Copy link
Member Author
hius07 commented Sep 5, 2023

I postponed it, want to understand why they are similar

function ReaderTypeset:toggleEmbeddedFonts(toggle)
self.ui.document:setEmbeddedFonts(toggle)
self.ui:handleEvent(Event:new("UpdatePos"))
end

function ReaderTypeset:toggleImageScaling(toggle)
self.ui.document:setImageScaling(toggle)
self.ui:handleEvent(Event:new("UpdatePos"))
end

but are called from onReadSettings differently
self.ui.document:setEmbeddedFonts(0)

self:toggleImageScaling(self.configurable.smooth_scaling == 1)

ie, is this UpdatePos really needed for smooth_scaling and nightmode_images.

@poire-z
Copy link
Contributor
poire-z commented Sep 5, 2023

but are called from onReadSettings differently

There may be no real answer or logic - depends on the people who implemented each over the years :/ and their preference between shortcuts or always using a single method :) (I'm not sure in which camp you are :)

ie, is this UpdatePos really needed for smooth_scaling and nightmode_images.

Possibly not, but we will need a redraw. Usually, UpdatePos is dumb/clever enough to ask crengine to compute its hashes to see if a rerendering is needed, and tell frontend that - and UpdatePos should do the right thing in both cases.

@hius07
Copy link
Member Author
hius07 commented Sep 5, 2023

but we will need a redraw

I'm talking about onReadSettings only.
Maybe it's better to call UpdatePos once in the end, instead of calling it after reading each setting.

@poire-z
Copy link
Contributor
poire-z commented Sep 5, 2023

Maybe it's better to call UpdatePos once in the end, instead of calling it after reading each setting.

It shouldn't be needed in the onReadSettings() phase - and it is actually a no-op:

function ReaderRolling:onUpdatePos(force)
if self.batched_update_count > 0 then
return
end
if self.ui.postReaderCallback ~= nil then -- ReaderUI:init() not yet done
-- Don't schedule any updatePos as long as ReaderUI:init() is
-- not finished (one will be called in the ui.postReaderCallback
-- we have set above) to avoid multiple refreshes.
return true
end

So, I guess that if you see it called, it's because the same individual methods used for setting settings after init are called while in onReadSettings - and it shouldn't hurt. So, it comes down to the 2 camps I mentionned above :)

Comment on lines 35 to 39
-- default to enable embedded fonts
-- As this is new, call it only when embedded_fonts are explicitely disabled
-- self.ui.document:setEmbeddedFonts(self.embedded_fonts and 1 or 0)
if not self.embedded_fonts then
if self.configurable.embedded_fonts == 0 then
self.ui.document:setEmbeddedFonts(0)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

"At this is new..." is my writting from 2017 :) and I was probably very cautious at the time.
It feels now that you don't need that if, and you could just set it always, even if it's 1.

@poire-z
Copy link
Contributor
poire-z commented Sep 5, 2023

Should probably not block this work, but pinging @yparitcher the author (and may be only user ? :) of the docsettingtweak.koplugin plugin: can users be affected with these deduplications, if they use the removed version of the setting - and how likely they would be to use the removed or the kept setting names. Or are all the settings @hius07 is playing with not really candidates for user per-directory customisation ?

@Frenzie
Copy link
Member
Frenzie commented Sep 5, 2023

(and may be only user ? :)

I do like the idea for some use cases but I admit I don't actually use it. :-)

@yparitcher
Copy link
Member

Currently i set both eitherway (for example: font_size & copt_font_size) one does the actual change and one gets it to show up in the bottom menu.

@hius07 hius07 merged commit 5e74f29 into koreader:master Sep 6, 2023
2 checks passed
@hius07 hius07 deleted the copt-embedded_css branch September 6, 2023 06:41
@hius07 hius07 added this to the 2023.09 milestone Sep 6, 2023
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.

4 participants