Skip to content

style: Move border-image-repeat outside of mako. - #19668

Closed
collares wants to merge 2 commits into
servo:masterfrom
collares:border-image-repeat
Closed

collares wants to merge 2 commits into
servo:masterfrom
collares:border-image-repeat

Conversation

@collares

@collares collares commented Jan 1, 2018 •

Copy link
Copy Markdown
Contributor

Part of #19015.

r? emilio



This change is Reviewable

@highfive

highfive commented Jan 1, 2018

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon.

@highfive

highfive commented Jan 1, 2018

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/values/specified/border.rs, components/style/values/specified/mod.rs, components/style/values/computed/border.rs, components/style/values/computed/mod.rs and 1 more
  • @canaltinova: components/style/properties/gecko.mako.rs, components/style/values/specified/border.rs, components/style/values/specified/mod.rs, components/style/values/computed/border.rs, components/style/values/computed/mod.rs and 1 more
  • @emilio: components/layout/display_list_builder.rs, components/style/properties/gecko.mako.rs, components/style/values/specified/border.rs, components/style/values/specified/mod.rs, components/style/values/computed/border.rs and 2 more

@highfive

highfive commented Jan 1, 2018

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style and layout code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 1, 2018
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
SpecifiedBorderImageRepeat(computed.0, Some(computed.1))
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you can impl ToComputedValue for BorderImageRepeat inside specified module like BorderSideWidth in specified/border.rs.

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.

Oh yeah, it should have been in specified/border.rs. Thanks for catching that :)

@collares collares Jan 1, 2018 •

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.

Now that I think about it, I believe the reason BorderSideWidth can be in specified/border.rs is that its computed value is particularly simple (computed::NonNegativeLength). I don't think making specified/border.rs depend on computed/border.rs (for its ComputedValue) would be a good idea. If you think the cyclic dependency is not a problem, though, I can move it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's okay to make it depend on computed/border.rs.

You can also check specified/font.rs.
It import font as computed

use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue};

and use in the specified module.

Ex.

impl ToComputedValue for FontVariantEastAsian {
type ComputedValue = computed::FontVariantEastAsian;
fn to_computed_value(&self, _context: &Context) -> computed::FontVariantEastAsian {
match *self {
FontVariantEastAsian::Value(ref v) => v.clone(),
FontVariantEastAsian::System(_) => {
#[cfg(feature = "gecko")] {
_context.cached_system_font.as_ref().unwrap().font_variant_east_asian.clone()
}
#[cfg(feature = "servo")] {
unreachable!()
}
}
}
}
fn from_computed_value(other: &computed::FontVariantEastAsian) -> Self {
FontVariantEastAsian::Value(other.clone())
}
}

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.

I see, that is good to know!

I don't mean to be difficult, but I wanted to understand why one way is better than the other, as they look mostly the same to me. I grepped for "impl ToComputedValue" and specified/ has 33 impls (12 of them in font.rs), while computed/ has 15 impls (including background-repeat, on which I based this). I understand you have been working on this a lot, so a completely valid reason would be something like "Consistency is good and I prefer us to standardise on this" :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're not consistent at this at all, I filed #19670. IIRC @nox had a stronger opinion than me at this regarding dependencies from computed to specified and vice-versa, so if it's not very urgent we could wait for different arguments to come in there and then make a decision and move all of them :)

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great, thanks @mauricioc!

}
}

impl ToComputedValue for SpecifiedBorderImageRepeat {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's fine to keep this consistent with BackgroundRepeat for now.

///
/// https://drafts.csswg.org/css-backgrounds/#propdef-border-image-repeat
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub struct BorderImageRepeat(pub RepeatKeyword, pub RepeatKeyword);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We already have a RepeatKeyword in the background module, maybe rename that one as BackgroundRepeatKeyword, and this as BorderImageRepeatKeyword as a followup?

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.

(Background)RepeatKeyword appeared in gecko.mako.rs in two places before my changes. The first one is clearly rename-able, but the second one is in fn to_servo(repeat: StyleImageLayerRepeat) -> RepeatKeyword. Is RepeatKeyword being used here in the background sense, or is it being reused for some other purpose? Does this affect the renaming decision? Either way, I've renamed the RepeatKeyword I just added to BorderImageRepeatKeyword.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ImageLayerRepeat is definitely related to backgrounds in Gecko terminology, so I think it's fine to rename both.

@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 9695d49 has been approved by emilio

@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 Jan 1, 2018
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 1, 2018
@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 9a58fd7 has been approved by emilio

@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 Jan 1, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 9a58fd7 with merge 8dacd16...

bors-servo pushed a commit that referenced this pull request Jan 1, 2018
style: Move border-image-repeat outside of mako.

Part of #19015.

r? emilio

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach build-geckolib` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #19021
- [X] These changes do not require tests

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19668)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 1, 2018
@collares

collares commented Jan 1, 2018 •

Copy link
Copy Markdown
Contributor Author

Due to some miscommunication, there is a parallel PR for the same issue (I noticed this by coincidence while checking bors' queue). Since I believe this is a great first bug, since I forgot about this one for a long time, and since the other PR has been in the works for a while, I am giving it priority and closing this one. I will do #19671 instead :)

@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

For the record, the other PR is #19210, sorry I didn't caught that before :(

bors-servo pushed a commit that referenced this pull request Feb 1, 2018
style: Move border-image-repeat outside of mako.

This is a rebased / nitpick-addressed / bug-fixed version of #19021, and with a commit from #19668 renaming the two `RepeatKeyword`s to different names.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19924)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Feb 1, 2018
style: Move border-image-repeat outside of mako.

This is a rebased / nitpick-addressed / bug-fixed version of #19021, and with a commit from #19668 renaming the two `RepeatKeyword`s to different names.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19924)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Feb 1, 2018
style: Move border-image-repeat outside of mako.

This is a rebased / nitpick-addressed / bug-fixed version of #19021, and with a commit from #19668 renaming the two `RepeatKeyword`s to different names.

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

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move border-image-repeat outside of mako.

5 participants