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

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

Closed
wants to merge 1 commit into from

Conversation

@chansuke
Copy link
Contributor

chansuke commented Nov 14, 2017


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #19142.

This change is Reviewable

Copy link
Member

emilio left a comment

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) {

This comment has been minimized.

@emilio

emilio Nov 14, 2017

Member

There's no need for match here, just:

let BorderImageRepeat(horizontal, vertical) = *self;

This comment has been minimized.

@emilio

emilio Jan 21, 2018

Member

This comment still applies.


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

This comment has been minimized.

@emilio

emilio Nov 14, 2017

Member

Thid doesn't build does it?

This comment has been minimized.

@emilio

emilio Nov 18, 2017

Member

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

highfive commented Nov 14, 2017

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

highfive commented Nov 14, 2017

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

highfive commented Nov 14, 2017

warning Warning warning

  • These commits modify style and layout code, but no tests are modified. Please consider adding a test!
@chansuke
Copy link
Contributor Author

chansuke commented Nov 16, 2017

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

@@ -1680,8 +1681,8 @@ impl FragmentDisplayListBuilding for Fragment {
corners.3.resolve(webrender_image.width)),
// TODO(gw): Support border-image-outset
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),

This comment has been minimized.

@emilio

emilio Nov 18, 2017

Member

This is also not compiling, I think

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

This comment has been minimized.

@emilio

emilio Nov 18, 2017

Member

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

This comment has been minimized.

@chansuke

chansuke Nov 23, 2017

Author Contributor

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


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

This comment has been minimized.

@emilio

emilio Nov 18, 2017

Member

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
Copy link
Contributor Author

chansuke commented Dec 2, 2017

@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
Copy link
Member

emilio commented Dec 14, 2017

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
Contributor

bors-servo commented Dec 15, 2017

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

@chansuke
Copy link
Contributor Author

chansuke commented Dec 16, 2017

@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
Copy link
Collaborator

CYBAI commented Dec 16, 2017

@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
Contributor Author

chansuke commented Dec 16, 2017

@CYBAI Thanks!

@chansuke chansuke force-pushed the chansuke:remove-border-image-repeat branch 3 times, most recently from c397ba9 to 64a425f Dec 16, 2017
@jdm
Copy link
Member

jdm commented Dec 18, 2017

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 label Dec 18, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Dec 21, 2017

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

@chansuke
Copy link
Contributor Author

chansuke commented Dec 30, 2017

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

@chansuke chansuke force-pushed the chansuke:remove-border-image-repeat branch from 64a425f to ef597cd Dec 31, 2017
@emilio emilio mentioned this pull request Jan 1, 2018
5 of 5 tasks complete
@emilio
Copy link
Member

emilio commented Jan 1, 2018

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
Contributor

bors-servo commented Jan 2, 2018

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

@chansuke
Copy link
Contributor Author

chansuke commented Jan 12, 2018

@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 chansuke:remove-border-image-repeat branch from ef597cd to ccef94c Jan 12, 2018
@CYBAI
Copy link
Collaborator

CYBAI commented Jan 12, 2018

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 chansuke:remove-border-image-repeat branch 3 times, most recently from dc8cc2a to bbd0807 Jan 13, 2018
@chansuke
Copy link
Contributor Author

chansuke commented Jan 21, 2018

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

Copy link
Member

emilio left a comment

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>),

This comment has been minimized.

@emilio

emilio Jan 21, 2018

Member

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 {

This comment has been minimized.

@emilio

emilio Jan 21, 2018

Member

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))

This comment has been minimized.

@emilio

emilio Jan 21, 2018

Member

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) {

This comment has been minimized.

@emilio

emilio Jan 21, 2018

Member

This comment still applies.

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

This comment has been minimized.

@CYBAI

CYBAI Jan 21, 2018

Collaborator

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))

This comment has been minimized.

@CYBAI

CYBAI Jan 21, 2018

Collaborator

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 chansuke:remove-border-image-repeat branch from bbd0807 to f3347ef Jan 22, 2018
@chansuke chansuke force-pushed the chansuke:remove-border-image-repeat branch from f3347ef to 0149703 Jan 22, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Feb 1, 2018

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

@emilio
Copy link
Member

emilio commented Feb 1, 2018

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
Copy link
Contributor Author

chansuke commented Feb 2, 2018

@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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

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