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

Default is top-to-bottom if unset, not bottom-to-top #14746

Merged
merged 1 commit into from Dec 28, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Default is top-to-bottom if unset, not bottom-to-top

  • Loading branch information
DominoTree committed Dec 28, 2016
commit 23d4f04ce5a726e824490f03587762e6b59d1ec2
@@ -470,7 +470,7 @@ impl ToComputedValue for specified::AngleOrCorner {
fn to_computed_value(&self, _: &Context) -> AngleOrCorner {
match *self {
specified::AngleOrCorner::None => {
AngleOrCorner::Angle(Angle(0.0))
AngleOrCorner::Angle(Angle(PI))
},
specified::AngleOrCorner::Angle(angle) => {
AngleOrCorner::Angle(angle)
@@ -2,10 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use app_units::Au;
use cssparser::Parser;
use euclid::size::Size2D;
use media_queries::CSSErrorReporterTest;
use std::f32::consts::PI;
use style::parser::ParserContext;
use style::stylesheets::Origin;
use style::values::computed;
use style::values::computed::{Angle, Context, ToComputedValue};
use style::values::specified;
use style::values::specified::image::*;
use style_traits::ToCss;

@@ -32,6 +38,14 @@ fn test_linear_gradient() {

// Parsing without <angle> and <side-or-corner>
assert_roundtrip_with_context!(Image::parse, "linear-gradient(red, green)");

// AngleOrCorner::None should become AngleOrCorner::Angle(Angle(PI)) when parsed

This comment has been minimized.

@shinglyu

shinglyu Dec 28, 2016

Member

Maybe add a link to the spec in the comment. Or at least make clear that PI means "top-to-bottom". :)

// Note that Angle(PI) is correct for top-to-bottom rendering, whereas Angle(0) would render bottom-to-top.
// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/angle
let container = Size2D::new(Au::default(), Au::default());
let specified_context = Context::initial(container, true);
assert_eq!(specified::AngleOrCorner::None.to_computed_value(&specified_context),
computed::AngleOrCorner::Angle(Angle(PI)));
}

#[test]
@@ -19,11 +19,15 @@
#c {
background: linear-gradient(90deg, violet, violet 1em, violet 2ex, violet 50%, blue 50%, blue, blue);
}
#d {
background: linear-gradient(red, green);
}
</style>
</head>
<body>
<section id=a></section>
<section id=b></section>
<section id=c></section>
<section id=d></section>
</body>
</html>
@@ -30,6 +30,9 @@
background: blue;
right: 0;
}
#d {
background: linear-gradient(to bottom, red, green);
}
</style>
</head>
<body>
@@ -39,5 +42,6 @@
<nav id=ca></nav>
<nav id=cb></nav>
</section>
<section id=d></section>
</body>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.