Closed Bug 1224761 Opened 9 years ago Closed 9 years ago

Gradient with two color-stops at 0% renders as if second color stop were at 100%

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: dholbert, Assigned: dbaron)

References

Details

(Keywords: testcase)

Attachments

(2 files)

Attached file testcase 1
STR:
 1. Load attached testcase.

ACTUAL RESULTS:
 Second box has a gradient going from yellow at the left to blue at the right.

EXPECTED RESULTS:
 Second box should be entirely yellow.


This box has "linear-gradient(to right, blue 0%, yellow 0%);", which means we should be at yellow by the time we hit the left edge of the div (0%) and there shouldn't be any color changing to the right of that.

The other boxes in this testcase show that we're consistent about this for other values (e.g. -5%, 30%, 100%, 150%), but not for 0%.  It's not shown in the testcase, but we also show EXPECTED RESULTS if I use "blue -1%, yellow 0%" (bumping down the blue percentage slightly).  We just get things wrong if both color-stops are at 0%.

Chrome 48 & latest Edge show EXPECTED RESULTS. Firefox Nightly 45 shows ACTUAL RESULTS.
(Firefox 42 shows ACTUAL RESULTS, too. So, not a regression, or not a recent one at least.)
The place to start debugging this is probably nsCSSRendering::PaintGradient.
So I debugged what was going on in nsCSSRendering::PaintGradient, and everything there seemed reasonable, except for one interesting thing:  we hit the case that sets forceRepeatToCoverTiles to true.  We hit that only in the buggy case and not in the other 4 cases in dholbert's testcase.
Blocks: 768775
Assignee: nobody → dbaron
I tested locally in the reftest harness that the reftest fails as
expected (the second box shows a gradient) without the patch, and passes
with the patch.

(The reftest test is dholbert's testcase from the bug, unmodified; I
wrote the reference.)
Attachment #8691183 - Flags: review?(roc)
Thanks for fixing this, dbaron!

With this bug fixed, we should also be able to simplify the gradient expression in the following reference case to just "background: yellow" (which is what it should be equivalent to, anyway):
https://mxr.mozilla.org/mozilla-central/source/layout/reftests/webkit-gradient/webkit-gradient-linear-2-ref.html?mark=35-41&force=1#35

(Note the comment there pointing to this bug. The corresponding testcase has a gradient expression that approximately maps to the broken piece of this testcase, and the reference case does as well. Right now they each render as a smooth gradient, and once this is fixed, they'll both render as solid-yellow.  And at that point, there's no reason for us to use the complex gradient expression in the reference case anymore, & we can just simplify to "background:yellow".)

If you're up for making this reference-case tweak as part of this bug here, great -- otherwise, I can also do it separately.
(In reply to Daniel Holbert [:dholbert] from comment #5)
> With this bug fixed, we should also be able to simplify the gradient
> expression in the following reference case to just "background: yellow"
> (which is what it should be equivalent to, anyway):
> https://mxr.mozilla.org/mozilla-central/source/layout/reftests/webkit-
> gradient/webkit-gradient-linear-2-ref.html?mark=35-41&force=1#35

Sure, I'll land that as patch by you with r=dbaron.
Ah, great - thanks!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: