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

flexbox: initial attempt to add support for RTL direction #1225

Merged
merged 6 commits into from
Oct 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 58 additions & 5 deletions weasyprint/tests/test_layout/test_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def test_flex_direction_row_rtl():
div_2.position_y ==
div_3.position_y ==
article.position_y)
assert div_1.position_x == article.width - div_1.padding_width()
assert (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liZe please verify if this test is correct.

div_1.position_x + div_1.width ==
article.position_x + article.width)
assert div_1.position_x > div_2.position_x > div_3.position_x


Expand Down Expand Up @@ -111,10 +113,7 @@ def test_flex_direction_row_reverse_rtl():
div_2.position_y ==
div_3.position_y ==
article.position_y)
# below assert needs to be fixed
assert (
div_3.position_x + div_3.width ==
article.position_x + article.width)
assert div_3.position_x == article.position_x
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liZe please verify if this test is correct.

assert div_1.position_x > div_2.position_x > div_3.position_x


Expand Down Expand Up @@ -143,6 +142,32 @@ def test_flex_direction_column():
assert div_1.position_y < div_2.position_y < div_3.position_y


@assert_no_logs
def test_flex_direction_column_rtl():
page, = render_pages('''
<article style="display: flex; flex-direction: column;
direction: rtl">
<div>A</div>
<div>B</div>
<div>C</div>
</article>
''')
html, = page.children
body, = html.children
article, = body.children
div_1, div_2, div_3 = article.children
assert div_1.children[0].children[0].text == 'A'
assert div_2.children[0].children[0].text == 'B'
assert div_3.children[0].children[0].text == 'C'
assert (
div_1.position_x ==
div_2.position_x ==
div_3.position_x ==
article.position_x)
assert div_1.position_y == article.position_y
assert div_1.position_y < div_2.position_y < div_3.position_y


@assert_no_logs
def test_flex_direction_column_reverse():
page, = render_pages('''
Expand Down Expand Up @@ -170,6 +195,34 @@ def test_flex_direction_column_reverse():
assert div_1.position_y < div_2.position_y < div_3.position_y


@assert_no_logs
def test_flex_direction_column_reverse_rtl():
page, = render_pages('''
<article style="display: flex; flex-direction: column-reverse;
direction: rtl">
<div>A</div>
<div>B</div>
<div>C</div>
</article>
''')
html, = page.children
body, = html.children
article, = body.children
div_1, div_2, div_3 = article.children
assert div_1.children[0].children[0].text == 'C'
assert div_2.children[0].children[0].text == 'B'
assert div_3.children[0].children[0].text == 'A'
assert (
div_1.position_x ==
div_2.position_x ==
div_3.position_x ==
article.position_x)
assert (
div_3.position_y + div_3.height ==
article.position_y + article.height)
assert div_1.position_y < div_2.position_y < div_3.position_y


@assert_no_logs
def test_flex_row_wrap():
page, = render_pages('''
Expand Down