servo: Merge #17971 - Always set mBgPos for LineDirection::Vertical (from upsuper:linear-gradient); r=canaltinova
authorXidorn Quan <me@upsuper.org>
Fri, 04 Aug 2017 04:31:19 -0500
changeset 422368 76dcd1e6797b48a6e4b061b6c1865ae037e24812
parent 422367 1014c8e695a6ea680917717b4caf9c8c26eab563
child 422369 797d8666721f4f192ee1f075b41faccf4fc0cdec
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscanaltinova
bugs17971, 1385469
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17971 - Always set mBgPos for LineDirection::Vertical (from upsuper:linear-gradient); r=canaltinova This fixes [bug 1385469](https://bugzilla.mozilla.org/show_bug.cgi?id=1385469). Source-Repo: https://github.com/servo/servo Source-Revision: 187254bf26fc9974c65d061a146bbbbfb484fbd3
servo/components/style/gecko/conversions.rs
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -224,24 +224,28 @@ impl nsStyleImage {
                         unsafe {
                             (*gecko_gradient).mBgPosX
                                              .set_value(CoordDataValue::Percent(x));
                             (*gecko_gradient).mBgPosY
                                              .set_value(CoordDataValue::Percent(0.5));
                         }
                     },
                     LineDirection::Vertical(y) => {
-                        // Y::Bottom (to bottom) is ignored because it is the default value.
-                        if y == Y::Top {
-                            unsafe {
-                                (*gecko_gradient).mBgPosX
-                                                 .set_value(CoordDataValue::Percent(0.5));
-                                (*gecko_gradient).mBgPosY
-                                                 .set_value(CoordDataValue::Percent(0.0));
-                            }
+                        // Although bottom is the default value, we can not ignore
+                        // it here, because the rendering code of Gecko relies on
+                        // this to behave correctly for legacy mode.
+                        let y = match y {
+                            Y::Top => 0.0,
+                            Y::Bottom => 1.0,
+                        };
+                        unsafe {
+                            (*gecko_gradient).mBgPosX
+                                                .set_value(CoordDataValue::Percent(0.5));
+                            (*gecko_gradient).mBgPosY
+                                                .set_value(CoordDataValue::Percent(y));
                         }
                     },
                     LineDirection::Corner(horiz, vert) => {
                         let percent_x = match horiz {
                             X::Left => 0.0,
                             X::Right => 1.0,
                         };
                         let percent_y = match vert {