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

Properly account for relative CSS units in borders, margins, padding, an... #602

Merged
merged 5 commits into from Jul 19, 2013

Conversation

@metajack
Copy link
Contributor

metajack commented Jul 19, 2013

...d widths.

let br = base.model.compute_border_width(self.style().border_right_width());
let style = self.style();
let font_size = style.font_size();
let w = MaybeAuto::from_width(style.width(),

This comment has been minimized.

@pcwalton

pcwalton Jul 19, 2013

Contributor

I'm not really a fan of these one- or two-letter variable names, especially in layout code which needs to be clear.

let font_size = style.font_size();
let w = MaybeAuto::from_width(style.width(),
Au(0),
font_size).spec_or_default(Au(0));

This comment has been minimized.

@pcwalton

pcwalton Jul 19, 2013

Contributor

Maybe it's worth having a spec_or_zero() here that uses the Zero trait? (I don't actually know what spec means: specified I guess? Another naming nit.)

}
CSSPaddingLength(Px(v)) => Au::from_frac_px(v),
CSSPaddingLength(Pt(v)) => Au::from_pt(v),
CSSPaddingLength(Em(em)) => match font_size {

This comment has been minimized.

@pcwalton

pcwalton Jul 19, 2013

Contributor

nit: brace all multi-line pattern arms.

}
CSSBorderWidthLength(Px(v)) => Au::from_frac_px(v),
CSSBorderWidthLength(Pt(v)) => Au::from_pt(v),
CSSBorderWidthLength(Em(em)) => match font_size {

This comment has been minimized.

@pcwalton

pcwalton Jul 19, 2013

Contributor

nit: brace all multi-line pattern arms.

self.padding.right = self.compute_padding_length(style.padding_right(), cb_width);
self.padding.bottom = self.compute_padding_length(style.padding_bottom(), cb_width);
self.padding.left = self.compute_padding_length(style.padding_left(), cb_width);
pub fn compute_padding(&mut self, style: CompleteStyle, cb_width: Au) {

This comment has been minimized.

@pcwalton

pcwalton Jul 19, 2013

Contributor

nit: what is cb here? Containing box? Abbreviations in layout code are confusing :(

CSSWidthLength(Em(v)) => Specified(Au::from_frac_px(v)),
CSSWidthLength(Px(v)) => Specified(Au::from_frac_px(v)),
CSSWidthLength(Pt(v)) => Specified(Au::from_pt(v)),
CSSWidthLength(Em(em)) => match font_size {

This comment has been minimized.

@pcwalton

pcwalton Jul 19, 2013

Contributor

nit: brace all multi-line pattern arms.

}
}

pub fn from_width(width: CSSWidth, cb_width: Au) -> MaybeAuto{
match width{
pub fn from_width(width: CSSWidth, cb_width: Au, font_size: CSSFontSize) -> MaybeAuto {

This comment has been minimized.

@pcwalton

pcwalton Jul 19, 2013

Contributor

nit: as below I think cb_width is confusing. I guess it's "containing box", not "content box"?

metajack added 4 commits Jul 19, 2013
`spec_or_default` is now `specified_or_default` and `specified_or_zero` was
added to handle the most common case.
@pcwalton

This comment has been minimized.

Copy link

pcwalton commented on 11af5ff Jul 19, 2013

r+

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented on 11af5ff Jul 19, 2013

saw approval from pcwalton
at metajack@11af5ff

This comment has been minimized.

Copy link
Contributor

bors-servo replied Jul 19, 2013

merging metajack/servo/relative-bpm = 11af5ff into auto

This comment has been minimized.

Copy link
Contributor

bors-servo replied Jul 19, 2013

metajack/servo/relative-bpm = 11af5ff merged ok, testing candidate = b68b573

This comment has been minimized.

Copy link
Contributor

bors-servo replied Jul 19, 2013

fast-forwarding master to auto = b68b573

bors-servo pushed a commit that referenced this pull request Jul 19, 2013
@bors-servo bors-servo merged commit 11af5ff into servo:master Jul 19, 2013
1 check passed
1 check passed
default all tests passed
glennw pushed a commit to glennw/servo that referenced this pull request Jan 16, 2017
Use strongly typed geometry - Part 2

Use strongly typed geometry in the public API. This changeset adds the LayoutPixel unit which is basically an alias to LayerPixel.
I think that it's best to keep the "Layer" terminology internal to webrender, and since the 1-1 correspondence between the api's layout pixels and internal layer pixels is somewhat coincidental, it will help to have separate names if things like async zoom introduce an actual difference between the two coordinate spaces (as it does in Gecko). Using an alias instead of a separate type comes from a mix of laziness (not having to cast from layout t layer pixels all over frame.rs) and the fact that currently layer and layout pixels are the same thing, but I'll add a separate unit if there is a preference for it.

I did not introduce ParentLayoutPixel. I don't know the API well enough yet to be sure whether some geometry is passed in a stacking context's parent coordinate space, but if so we should consider introducing a special unit for it, if only for the sake of proper documentation.

This PR is a lot easier to rebase than part 1 and is a breaking change to the public API, so it's fine to wait a bit if there are cross-crates changes that we want to coordinate before having to adapt servo to this (although it should be easy to do).

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/602)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.