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

use Either type for UrlOrNone #14370

Merged
merged 1 commit into from Dec 2, 2016
Merged

use Either type for UrlOrNone #14370

merged 1 commit into from Dec 2, 2016

Conversation

@thiagopnts
Copy link
Contributor

thiagopnts commented Nov 25, 2016

Use the Either type for UrlOrNone


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #14298 (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Nov 25, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/properties/longhand/list.mako.rs, components/style/properties/shorthand/list.mako.rs, components/style/values/mod.rs, components/style/parser.rs, components/style/values/specified/mod.rs, components/style/properties/helpers.mako.rs, components/style/values/specified/url.rs, components/style/properties/longhand/box.mako.rs
  • @emilio: components/style/properties/gecko.mako.rs, components/style/properties/longhand/list.mako.rs, components/style/properties/shorthand/list.mako.rs, components/style/values/mod.rs, components/style/parser.rs, components/style/values/specified/mod.rs, components/layout/construct.rs, components/style/properties/helpers.mako.rs, components/style/values/specified/url.rs, components/style/properties/longhand/box.mako.rs
@highfive
Copy link

highfive commented Nov 25, 2016

warning Warning warning

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

emilio commented Nov 25, 2016

Hey, thanks for the patch!

Looks good, though you also need to fix the stylo build (./mach test-stylo).

From the error, should be straigh-forward, but feel free to ping me if you have any doubts!

Thanks again! :)

@emilio
Copy link
Member

emilio commented Nov 25, 2016

(Sorry, I meant to say ./mach build-geckolib, though ./mach test-stylo should pass with that too :)

let image_info = box ImageFragmentInfo::new(node,
url_value.url().map(|u| u.clone()),
&self.layout_context.shared);
vec![Fragment::new(node, SpecificFragmentInfo::Image(image_info), self.layout_context)]
}
list_style_image::T::None => {
Either::Second(_) => {

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 26, 2016

Member

The problem with Either type is that, it doesn't even give you a hint of what it holds under. We should do a workaround like this,

Either::Second(_none) => {

... so that we can convince ourselves that it really holds a None type.

match image {
UrlOrNone::None => {
Either::Second(_) => {

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 26, 2016

Member

ditto about _none

@@ -74,3 +74,7 @@ pub fn log_css_error(input: &mut Parser, position: SourcePosition, message: &str
pub trait Parse {
fn parse(input: &mut Parser) -> Result<Self, ()> where Self: Sized;
}

pub trait ParseWithContext {

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 26, 2016

Member

This should be a temporary fix. We should probably replace all the types implementing the Parse method to take the context. You can do it if you like, but in case you don't, please drop a FIXME above this, like, FIXME(waffles): Merge this with Parse

This comment has been minimized.

Copy link
@emilio

emilio Nov 26, 2016

Member

What about something like (probably with the traits renamed since we probably want ParseWithContext to be the default):

pub trait Parse : Sized {
    fn parse(input: &mut Parser) -> Result<Self, ()>;
}

pub trait ParseWithContext : Sized {
    fn parse_with_context(input: &mut Parser, context: &ParserContext) -> Result<Self, ()>;
}

impl<T: Parse> ParseWithContext for T {
    fn parse_with_context(input: &mut Parser, context: &ParserContext) -> Result<Self, ()> {
        T::parse(input)
    }
}

In any case agreed, this is kind of offtopic for this PR :)

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 26, 2016

Member

I've changed the function signature (#14373) to include the context to avoid this problem 😄

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 27, 2016

Member

@thiagopnts You won't be needing this trait anymore. We'll be using the context in all the parse functions. Please rebase your changes on top of master :)

This comment has been minimized.

Copy link
@thiagopnts

thiagopnts Nov 28, 2016

Author Contributor

Cool, I will do the changes

@bors-servo
Copy link
Contributor

bors-servo commented Nov 27, 2016

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

@thiagopnts
Copy link
Contributor Author

thiagopnts commented Nov 30, 2016

@emilio @wafflespeanut I did the changes, let me know if everything is ok so I can squash the commits!

@@ -54,6 +54,7 @@ use style::properties::{self, ServoComputedValues};
use style::selector_parser::{PseudoElement, RestyleDamage};
use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
use style::stylist::Stylist;
use style::values::{Either, None_};

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 30, 2016

Member

I don't think the type would be necessary. It's not gonna be used anywhere anyway. Instead, you can just bind it to a name, like so

Either::Second(_none) => (),
@@ -1089,10 +1089,10 @@ fn static_assert() {

#[allow(non_snake_case)]
pub fn set__moz_binding(&mut self, v: longhands::_moz_binding::computed_value::T) {
use properties::longhands::_moz_binding::computed_value::T as BindingValue;
use values::{Either, None_};

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 30, 2016

Member

ditto here and everywhere...

@@ -72,6 +73,12 @@ pub struct SpecifiedUrl {
extra_data: UrlExtraData,
}

impl Parse for SpecifiedUrl {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
SpecifiedUrl::parse(context, input)

This comment has been minimized.

Copy link
@wafflespeanut

wafflespeanut Nov 30, 2016

Member

We could just move the parse function here.

Copy link
Member

wafflespeanut left a comment

Once my comments have been addressed, squash the commits, and we'll land it :)

fix test-tidy errors

fix style unit test

use the Parse trait instead of ParseWithContext

fix stylo test and geckolib build

move all specified url parse code to parse trait and remove refs to unused type
@thiagopnts thiagopnts force-pushed the thiagopnts:master branch from 3ba11a5 to 206f4ea Nov 30, 2016
@thiagopnts
Copy link
Contributor Author

thiagopnts commented Dec 1, 2016

@wafflespeanut done :)

Copy link
Member

wafflespeanut left a comment

Thanks for working on this! :)

@wafflespeanut
Copy link
Member

wafflespeanut commented Dec 1, 2016

@highfive highfive assigned wafflespeanut and unassigned emilio Dec 1, 2016
@wafflespeanut
Copy link
Member

wafflespeanut commented Dec 1, 2016

@bors-servo r+

Wut?

@bors-servo
Copy link
Contributor

bors-servo commented Dec 1, 2016

📌 Commit 206f4ea has been approved by Wafflespeanut

@bors-servo
Copy link
Contributor

bors-servo commented Dec 1, 2016

Testing commit 206f4ea with merge 8c3b88d...

bors-servo added a commit that referenced this pull request Dec 1, 2016
use Either type for UrlOrNone

Use the Either type for UrlOrNone

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #14298 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/14370)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 1, 2016

💔 Test failed - linux-rel-wpt

@wafflespeanut
Copy link
Member

wafflespeanut commented Dec 2, 2016

@bors-servo retry

Nightmare'ish timeouts!

@bors-servo
Copy link
Contributor

bors-servo commented Dec 2, 2016

Testing commit 206f4ea with merge 290ff5c...

bors-servo added a commit that referenced this pull request Dec 2, 2016
use Either type for UrlOrNone

Use the Either type for UrlOrNone

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #14298 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/14370)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 2, 2016

@bors-servo bors-servo merged commit 206f4ea into servo:master Dec 2, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Dec 2, 2016
4 of 5 tasks complete
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.

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