Skip to content

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

Closed
chansuke wants to merge 1 commit into
servo:masterfrom
chansuke:remove-border-image-repeat
Closed

chansuke wants to merge 1 commit into
servo:masterfrom
chansuke:remove-border-image-repeat

Conversation

@chansuke

@chansuke chansuke commented Nov 14, 2017 •

Copy link
Copy Markdown
Contributor


This change is Reviewable

@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 has a couple of build errors, but it's a good start!

Let me know if I can help fixing them somehow.

where
W: fmt::Write,
{
match (self.0, self.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.

There's no need for match here, just:

let BorderImageRepeat(horizontal, vertical) = *self;

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 comment still applies.


#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match (computed) {

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.

Thid doesn't build does 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.

This is probably still not building, let me know if you need any help setting up the build environment or if I can help somehow, I'd be glad to :)

@highfive

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 @pcwalton (or someone else) soon.

@highfive

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/computed/border.rs, components/style/values/computed/mod.rs, components/style/properties/longhand/border.mako.rs
  • @canaltinova: components/style/properties/gecko.mako.rs, components/style/values/specified/border.rs, components/style/values/computed/border.rs, components/style/values/computed/mod.rs, components/style/properties/longhand/border.mako.rs
  • @emilio: components/layout/display_list_builder.rs, components/style/properties/gecko.mako.rs, components/style/values/specified/border.rs, components/style/values/computed/border.rs, components/style/values/computed/mod.rs and 1 more

@highfive

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 Nov 14, 2017
@chansuke

chansuke commented Nov 16, 2017 •

Copy link
Copy Markdown
Contributor Author

@emilio Thanks for the review!!I'll fix it:)

@jdm jdm assigned emilio and unassigned pcwalton Nov 16, 2017
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 16, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Nov 16, 2017
outset: SideOffsets2D::zero(),
repeat_horizontal: convert_repeat_mode(border_style_struct.border_image_repeat.0),
repeat_vertical: convert_repeat_mode(border_style_struct.border_image_repeat.1),
repeat_horizontal: convert_repeat_mode(border_style_struct.BorderImageRepeatKeyword.0),

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 is also not compiling, I think

where
W: fmt::Write,
{
let BorderImageRepeat(horizontal, vertical) = *self;

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.

Now you need to actually serialize them, keeping the code that existed.

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.

Ok.Thank you for the review.I'll fix it


#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match (computed) {

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 is probably still not building, let me know if you need any help setting up the build environment or if I can help somehow, I'd be glad to :)

@chansuke

chansuke commented Dec 2, 2017

Copy link
Copy Markdown
Contributor Author

@emilio Sorry for interval.I fixed little bit but stuck...I can't solve the build error below.

  • unresolved import values::specified::BorderImageRepeat
  • failed to resolve. Could not find BorderImageRepeat in specified
  • cannot find function get_initial_specified_value in module border_image_repeat

@emilio

emilio commented Dec 14, 2017

Copy link
Copy Markdown
Member

Sorry for the huge lag here @chansuke!

For the unresolved import, you need to export that value from values/specified/mod.rs.

For get_initial_specified_value error, you need to remove the vector=True bit.

Other than that it looks great!

@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #19568) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Dec 15, 2017
@chansuke

Copy link
Copy Markdown
Contributor Author

@emilio Thank you for your help!!I fixed the error.The remaining error is missing documentation for a method error but how can I solve this?

error: missing documentation for a method
  --> components/style/values/computed/border.rs:95:5
   |
95 | /     pub fn repeat() -> Self {
96 | |         BorderImageRepeat(RepeatKeyword::Repeat, RepeatKeyword::Repeat)
97 | |     }
   | |_____^
   |
note: lint level defined here
  --> components/style/values/mod.rs:9:9
   |
9  | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^

error: missing documentation for an enum
   --> components/style/values/specified/border.rs:184:1
    |
184 | / pub enum BorderImageRepeat {
185 | |     /// `[ stretch | repeat | round | space ]{1,2}`
186 | |     Keywords(RepeatKeyword, Option<RepeatKeyword>),
187 | | }
    | |_^

error: aborting due to 2 previous errors

@CYBAI

CYBAI commented Dec 16, 2017

Copy link
Copy Markdown
Member

@chansuke You only need to write documentation comments for them; then the error will disappear. Documentation comments in Rust always start with /// or //!.

For example, here are documentation comments for BorderSideWidth

/// A specified value for a single side of the `border-width` property.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub enum BorderSideWidth {
/// `thin`
Thin,
/// `medium`
Medium,
/// `thick`
Thick,
/// `<length>`
Length(Length),
}

Ref: Rust By Example - Documentation

@chansuke

Copy link
Copy Markdown
Contributor Author

@CYBAI Thanks!

@chansuke
chansuke force-pushed the remove-border-image-repeat branch 3 times, most recently from c397ba9 to 64a425f Compare December 17, 2017 06:58
@jdm

jdm commented Dec 18, 2017

Copy link
Copy Markdown
Member
error[E0432]: unresolved import `style::properties::longhands::computed_value`

  --> components/layout/display_list_builder.rs:61:35

   |

61 | use style::properties::longhands::computed_value::RepeatKeyword;

   |                                   ^^^^^^^^^^^^^^ Could not find `computed_value` in `longhands`

error[E0433]: failed to resolve. Use of undeclared type or module `BackgroundOrigin`

    --> components/layout/display_list_builder.rs:1449:13

     |

1449 |             BackgroundOrigin::BorderBox => {}

     |             ^^^^^^^^^^^^^^^^ Use of undeclared type or module `BackgroundOrigin`

error[E0433]: failed to resolve. Use of undeclared type or module `BackgroundOrigin`

    --> components/layout/display_list_builder.rs:1450:13

     |

1450 |             BackgroundOrigin::PaddingBox => {

     |             ^^^^^^^^^^^^^^^^ Use of undeclared type or module `BackgroundOrigin`

error[E0433]: failed to resolve. Use of undeclared type or module `BackgroundOrigin`

    --> components/layout/display_list_builder.rs:1457:13

     |

1457 |             BackgroundOrigin::ContentBox => {

     |             ^^^^^^^^^^^^^^^^ Use of undeclared type or module `BackgroundOrigin`

warning: unused import: `style::values::specified::border::RepeatKeyword as BorderImageRepeatKeyword`

  --> components/layout/display_list_builder.rs:76:5

   |

76 | use style::values::specified::border::RepeatKeyword as BorderImageRepeatKeyword;

   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   |

   = note: #[warn(unused_imports)] on by default

error[E0609]: no field `BorderImageRepeatKeyword` on type `&style::properties::style_structs::Border`

    --> components/layout/display_list_builder.rs:1707:88

     |

1707 |                             repeat_horizontal: convert_repeat_mode(border_style_struct.BorderImageRepeatKeyword.0),

     |                                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0609]: no field `BorderImageRepeatKeyword` on type `&style::properties::style_structs::Border`

    --> components/layout/display_list_builder.rs:1708:86

     |

1708 |                             repeat_vertical: convert_repeat_mode(border_style_struct.BorderImageRepeatKeyword.1),

     |                                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0609]: no field `BorderImageRepeatKeyword` on type `&style::properties::style_structs::Border`

    --> components/layout/display_list_builder.rs:1740:92

     |

1740 |                                 repeat_horizontal: convert_repeat_mode(border_style_struct.BorderImageRepeatKeyword.0),

     |                                                                                            ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0609]: no field `BorderImageRepeatKeyword` on type `&style::properties::style_structs::Border`

    --> components/layout/display_list_builder.rs:1741:90

     |

1741 |                                 repeat_vertical: convert_repeat_mode(border_style_struct.BorderImageRepeatKeyword.1),

     |                                                                                          ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 8 previous errors

error: Could not compile `layout`.

@jdm jdm removed the S-needs-rebase There are merge conflict errors. label Dec 18, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #19618) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Dec 21, 2017
@chansuke

Copy link
Copy Markdown
Contributor Author

Sorry for the lag.I will rebase and fix the error.

@chansuke
chansuke force-pushed the remove-border-image-repeat branch from 64a425f to ef597cd Compare December 31, 2017 12:47
@emilio

emilio commented Jan 1, 2018

Copy link
Copy Markdown
Member

Looks fine, but there are still Geckolib build errors (you can check them with ./mach build-geckolib or ./mach cargo-geckolib check)

@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #19651) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jan 2, 2018
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jan 3, 2018
@chansuke

Copy link
Copy Markdown
Contributor Author

@emilio Hi.I'm blocking with these build errors below.I was wondering if you could give me some suggestions.Thanks.

error[E0432]: unresolved import `style::properties::longhands::border_image_repeat::computed_value::RepeatKeyword`
  --> components/layout/display_list/builder.rs:67:5

error[E0611]: field `0` of tuple-struct `style::values::computed::BorderImageRepeat` is private
    --> components/layout/display_list/builder.rs:1452:33

error[E0611]: field `1` of tuple-struct `style::values::computed::BorderImageRepeat` is private
    --> components/layout/display_list/builder.rs:1455:33

error[E0611]: field `0` of tuple-struct `style::values::computed::BorderImageRepeat` is private
    --> components/layout/display_list/builder.rs:1492:37

error[E0611]: field `1` of tuple-struct `style::values::computed::BorderImageRepeat` is private
    --> components/layout/display_list/builder.rs:1495:37

@chansuke
chansuke force-pushed the remove-border-image-repeat branch from ef597cd to ccef94c Compare January 12, 2018 04:38
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Jan 12, 2018
@CYBAI

CYBAI commented Jan 12, 2018

Copy link
Copy Markdown
Member

Hi @chansuke
cc @emilio

With your patch, RepeatKeyword will be initiated from style::properties::longhands::border_image_repeat::computed_value.
Thus, you will need to import it from the enum your created in specified module.

use style::properties::longhands::border_image_repeat::computed_value::RepeatKeyword;

About other error messages which is tuple-struct style::values::computed::BorderImageRepeat is private, it means your struct fields should be public.

@chansuke
chansuke force-pushed the remove-border-image-repeat branch 3 times, most recently from dc8cc2a to bbd0807 Compare January 16, 2018 14:33
@chansuke

Copy link
Copy Markdown
Contributor Author

@emilio I fixed build errors.I wonder if you could check this.

@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.

Looks good! Some stuff still could be cleaner, but let me know if you just want to land this and we can tidy this up in followups :)

#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub enum BorderImageRepeat {
/// `[ stretch | repeat | round | space ]{1,2}`
Keywords(RepeatKeyword, Option<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.

This is just an enum with a single variant, so this can be a struct BorderImageRepeat(RepeatKeyword, Option<RepeatKeyword>), right?

/// An angle rounded and normalized per https://drafts.csswg.org/css-images/#propdef-image-orientation
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)]
pub enum Orientation {

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.

These changes are from another unrelated commit, so can just go away.

fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match (computed.0, computed.1) {
(horizontal, vertical) => {
SpecifiedBorderImageRepeat::Keywords(horizontal, Some(vertical))

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 can just be:

SpecifiedBorderImageRepeat::Keywords(computed.0, Some(computed.1))

Instead of this match expression.

where
W: fmt::Write,
{
match (self.0, self.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.

This comment still applies.

SpecifiedBorderImageRepeat::Keywords(horizontal, vertical) => {
BorderImageRepeat(horizontal, vertical.unwrap_or(horizontal))
}
}

@CYBAI CYBAI Jan 21, 2018 •

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'm wondering, when we only have only one pattern, will it be better to use if let here?

};

let vertical = input.try(RepeatKeyword::parse).ok();
Ok(BorderImageRepeat::Keywords(horizontal, vertical))

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.

IMO, the original parse method looks easier to understand for me.
Just curious if you met any difficulty when you tried to use the original method?

let first = RepeatKeyword::parse(input)?;
let second = input.try(RepeatKeyword::parse).ok();

Ok(SpecifiedValue(first, second))

@chansuke
chansuke force-pushed the remove-border-image-repeat branch from bbd0807 to f3347ef Compare January 22, 2018 17:09
@chansuke
chansuke force-pushed the remove-border-image-repeat branch from f3347ef to 0149703 Compare January 22, 2018 17:12
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #19903) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Feb 1, 2018
@emilio

emilio commented Feb 1, 2018

Copy link
Copy Markdown
Member

Sorry I didn't notice the followup commit @chansuke! I rebased, fixed the nits, and fixed the initial value, which you had changed to repeat instead of stretch, and opened #19924 with it.

Thanks a lot for the patch!

@jdm jdm closed this Feb 1, 2018
@chansuke

chansuke commented Feb 2, 2018

Copy link
Copy Markdown
Contributor Author

@emilio @CYBAI Thank you so much for taking the time!

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

Labels

S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move border-image-repeat outside of mako.

7 participants