Avoid multiple calls to getComputedStyle()

This commit is contained in:
Kovid Goyal 2020-07-27 13:42:13 +05:30
parent b0e1506976
commit 769ca0c59f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 5 deletions

View File

@ -164,8 +164,8 @@ def current_page_width():
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
line_height(True)
scroll_viewport.initialize_on_layout()
body_style = window.getComputedStyle(document.body)
scroll_viewport.initialize_on_layout(body_style)
first_layout = not _in_paged_mode
cps = calc_columns_per_screen()
if first_layout:

View File

@ -23,13 +23,13 @@ class ScrollViewport:
for attr in FUNCTIONS:
self[attr] = self[prefix + attr]
def initialize_on_layout(self):
self.rtl = False
self.ltr = True
body_style = window.getComputedStyle(document.body)
def initialize_on_layout(self, body_style):
if body_style.direction is "rtl":
self.rtl = True
self.ltr = False
else:
self.rtl = False
self.ltr = True
def flow_x(self):
if self.rtl: