Fix visibility() which was broken similar to pos_for_elem()

This commit is contained in:
Kovid Goyal 2020-08-13 20:14:37 +05:30
parent d7259dd2e2
commit 9a9f35ae43
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -564,21 +564,16 @@ anchor_funcs = {
scroll_viewport.rect_block_start(br), elem.ownerDocument), scroll_viewport.viewport_to_document_inline(scroll_viewport.rect_inline_start(br)) scroll_viewport.rect_block_start(br), elem.ownerDocument), scroll_viewport.viewport_to_document_inline(scroll_viewport.rect_inline_start(br))
, ,
'visibility': def visibility(pos): 'visibility': def visibility(pos):
x, y = pos y, x = pos
q = y if scroll_viewport.horizontal_writing_mode else x
if jstype(x) is 'number':
pos = x
if jstype(y) is 'number' and scroll_viewport.horizontal_writing_mode:
pos = y
# Have to negate X if in RTL for the math to be correct, # Have to negate X if in RTL for the math to be correct,
# as the value that the scroll viewport returns is negated # as the value that the scroll viewport returns is negated
if scroll_viewport.vertical_writing_mode and scroll_viewport.rtl: if scroll_viewport.vertical_writing_mode and scroll_viewport.rtl:
pos = -pos q = -q
if pos < scroll_viewport.block_pos(): if q < scroll_viewport.block_pos():
return -1 return -1
if pos <= scroll_viewport.block_pos() + scroll_viewport.block_size(): if q <= scroll_viewport.block_pos() + scroll_viewport.block_size():
return 0 return 0
return 1 return 1
, ,