Skip to content

gfx: Border radius support for asymmetric sized borders - #7370

Merged
bors-servo merged 1 commit into
servo:masterfrom
bjwbell:bugfix-unequal-borders
Aug 31, 2015
Merged

bors-servo merged 1 commit into
servo:masterfrom
bjwbell:bugfix-unequal-borders

Conversation

@bjwbell

@bjwbell bjwbell commented Aug 26, 2015

Copy link
Copy Markdown
Contributor

When the border-top/right/bottom/left-widths are not equal, the angle on the border corner arc separating the borders isn't PI/4.

For instance if the top border width is much larger than the left border width then most of the border corner should be drawn using the top border color.

This change adds support for calculating the correct angle in the border
corner arc for switching from one border to another e.g. the left border
to the top border.

It supports elliptical border radii for when elliptical border radii are
added.

A ref test is also included.

r? @Ms2ger

Review on Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 26, 2015
@Ms2ger

Ms2ger commented Aug 26, 2015

Copy link
Copy Markdown
Contributor

Not at all something for me.

r? @SimonSapin

@highfive highfive assigned SimonSapin and unassigned Ms2ger Aug 26, 2015
@bjwbell

bjwbell commented Aug 27, 2015

Copy link
Copy Markdown
Contributor Author

@SimonSapin ping or @pcwalton could review. Either one :-)

I have the code for adding almost all of elliptical border radius support ready to go after this PR.

Comment thread components/gfx/paint_context.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

presumably should be discriminant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch. Sorry about that.

@pcwalton

Copy link
Copy Markdown
Contributor

Do WebKit and Gecko implement the same algorithm? I'd like to see some comparisons between the way we do it and the way other browser engines do this.

Comment thread components/gfx/paint_context.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: only one space after ,

@bjwbell

bjwbell commented Aug 28, 2015

Copy link
Copy Markdown
Contributor Author

@pcwalton Gecko implements essentially the same algorithm (IntersectBorderRadius - https://dxr.mozilla.org/mozilla-central/source/layout/base/nsCSSRenderingBorders.cpp#1082).
They have optimizations for the easier cases e.g. all the borders are the same.

@bjwbell

bjwbell commented Aug 29, 2015

Copy link
Copy Markdown
Contributor Author

@pcwalton the code should be ready to review again.

@pcwalton

Copy link
Copy Markdown
Contributor

Looks good. Squash if you'd like, then I'll r+!

This change adds support for calculating the correct angle in the border
corner arc when switching from one border to another e.g. the left border
to the top border.

When the border-top/right/bottom/left-widths are not the same, the angle on
the border corner arc separating the borders isn't pi/4.

For example, if the top border width is much larger than the left border
width then most of the border corner should be drawn using the top
border color.

Elliptical border radii are supported for when elliptical border radii are
added.

The common case where borders have the same width sets the angle to
pi/4 directly.

A ref test is also included.
@bjwbell
bjwbell force-pushed the bugfix-unequal-borders branch from 7efe11a to d539b9b Compare August 31, 2015 20:07
@bjwbell bjwbell changed the title gfx: Border radius support for unequal sized borders gfx: Border radius support for asymmetric sized borders Aug 31, 2015
@pcwalton

Copy link
Copy Markdown
Contributor

@bors-servo: r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit d539b9b has been approved by pcwalton

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 31, 2015
bors-servo pushed a commit that referenced this pull request Aug 31, 2015
gfx: Border radius support for asymmetric sized borders

When the border-top/right/bottom/left-widths are not equal, the angle on the border corner arc separating the borders isn't PI/4. 

For instance if the top border width is much larger than the left border width then most of the border corner should be drawn using the top border color.

This change adds support for calculating the correct angle in the border
corner arc for switching from one border to another e.g. the left border
to the top border.

It supports elliptical border radii for when elliptical border radii are
added.

A ref test is also included.

r? @Ms2ger 

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7370)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit d539b9b with merge afc2c38...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants