mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Avoid multiple calls to getComputedStyle()
This commit is contained in:
parent
b0e1506976
commit
769ca0c59f
@ -164,8 +164,8 @@ def current_page_width():
|
|||||||
def layout(is_single_page, on_resize):
|
def layout(is_single_page, on_resize):
|
||||||
nonlocal _in_paged_mode, col_width, col_and_gap, screen_height, gap, screen_width, is_full_screen_layout, cols_per_screen, number_of_cols
|
nonlocal _in_paged_mode, col_width, col_and_gap, screen_height, gap, screen_width, is_full_screen_layout, cols_per_screen, number_of_cols
|
||||||
line_height(True)
|
line_height(True)
|
||||||
scroll_viewport.initialize_on_layout()
|
|
||||||
body_style = window.getComputedStyle(document.body)
|
body_style = window.getComputedStyle(document.body)
|
||||||
|
scroll_viewport.initialize_on_layout(body_style)
|
||||||
first_layout = not _in_paged_mode
|
first_layout = not _in_paged_mode
|
||||||
cps = calc_columns_per_screen()
|
cps = calc_columns_per_screen()
|
||||||
if first_layout:
|
if first_layout:
|
||||||
|
@ -23,13 +23,13 @@ class ScrollViewport:
|
|||||||
for attr in FUNCTIONS:
|
for attr in FUNCTIONS:
|
||||||
self[attr] = self[prefix + attr]
|
self[attr] = self[prefix + attr]
|
||||||
|
|
||||||
def initialize_on_layout(self):
|
def initialize_on_layout(self, body_style):
|
||||||
self.rtl = False
|
|
||||||
self.ltr = True
|
|
||||||
body_style = window.getComputedStyle(document.body)
|
|
||||||
if body_style.direction is "rtl":
|
if body_style.direction is "rtl":
|
||||||
self.rtl = True
|
self.rtl = True
|
||||||
self.ltr = False
|
self.ltr = False
|
||||||
|
else:
|
||||||
|
self.rtl = False
|
||||||
|
self.ltr = True
|
||||||
|
|
||||||
def flow_x(self):
|
def flow_x(self):
|
||||||
if self.rtl:
|
if self.rtl:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user